Skip to content

Commit e6ae199

Browse files
committed
!fixup address latest comments, thanks!
1 parent e86e71b commit e6ae199

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ void InnerLoopVectorizer::introduceCheckBlockInVPlan(BasicBlock *CheckIRBB) {
24862486
PreVectorPH->swapSuccessors();
24872487

24882488
// We just connected a new block to the scalar preheader. Update all
2489-
// ResumePhis by adding an incoming value for it, replacing the last value.
2489+
// ResumePhis by adding an incoming value for it, replicating the last value.
24902490
for (VPRecipeBase &R : *cast<VPBasicBlock>(ScalarPH)) {
24912491
auto *ResumePhi = dyn_cast<VPInstruction>(&R);
24922492
if (!ResumePhi || ResumePhi->getOpcode() != VPInstruction::ResumePhi)
@@ -2661,7 +2661,7 @@ void InnerLoopVectorizer::createVectorLoopSkeleton(StringRef Prefix) {
26612661
LoopScalarPreHeader =
26622662
SplitBlock(LoopVectorPreHeader, LoopVectorPreHeader->getTerminator(), DT,
26632663
LI, nullptr, Twine(Prefix) + "scalar.ph");
2664-
// NOTE: The Plan's scalar preheader isn't replaced with a VPIRBasicBlock
2664+
// NOTE: The Plan's scalar preheader VPBB isn't replaced with a VPIRBasicBlock
26652665
// wrapping LoopScalarPreHeader here at the moment, because the Plan's scalar
26662666
// preheader may be unreachable at this point. Instead it is replaced in
26672667
// createVectorizedLoopSkeleton.

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,18 +3529,25 @@ class VPlan {
35293529

35303530
/// Returns the 'middle' block of the plan, that is the block that selects
35313531
/// whether to execute the scalar tail loop or the exit block from the loop
3532-
/// latch. If the scalar tail loop or exit block are known to always execute,
3533-
/// the middle block may branch directly to the block.
3532+
/// latch. If there is an early exit from the vector loop, the middle block
3533+
/// conceptully has the early exit block as third successor, split accross 2
3534+
/// VPBBs. In that case, the second VPBB selects whether to execute the scalar
3535+
/// tail loop or the exit bock. If the scalar tail loop or exit block are
3536+
/// known to always execute, the middle block may branch directly to that
3537+
/// block. If there is no loop region, the middle block cannot be identified
3538+
/// and nullptr is returned.
35343539
VPBasicBlock *getMiddleBlock() {
35353540
VPRegionBlock *LoopRegion = getVectorLoopRegion();
35363541
if (!LoopRegion)
35373542
return nullptr;
3538-
auto *RegionSucc = LoopRegion->getSingleSuccessor();
3543+
auto *RegionSucc = cast<VPBasicBlock>(LoopRegion->getSingleSuccessor());
35393544
if (RegionSucc->getSingleSuccessor() ||
35403545
is_contained(RegionSucc->getSuccessors(), getScalarPreheader()))
3541-
return cast<VPBasicBlock>(RegionSucc);
3546+
return RegionSucc;
3547+
// There is an early exit. The successor of RegionSucc is the middle block.
35423548
return cast<VPBasicBlock>(RegionSucc->getSuccessors()[1]);
35433549
}
3550+
35443551
const VPBasicBlock *getMiddleBlock() const {
35453552
return const_cast<VPlan *>(this)->getMiddleBlock();
35463553
}

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ void VPlanTransforms::truncateToMinimalBitwidths(
16841684

16851685
/// Remove BranchOnCond recipes with true conditions together with removing
16861686
/// dead edges to their successors.
1687-
static void simplifyBranchOnCondTrue(VPlan &Plan) {
1687+
static void removeBranchOnCondTrue(VPlan &Plan) {
16881688
using namespace llvm::VPlanPatternMatch;
16891689
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
16901690
vp_depth_first_shallow(Plan.getEntry()))) {
@@ -1737,7 +1737,7 @@ void VPlanTransforms::optimize(VPlan &Plan) {
17371737
runPass(legalizeAndOptimizeInductions, Plan);
17381738
runPass(removeRedundantExpandSCEVRecipes, Plan);
17391739
runPass(simplifyRecipes, Plan, *Plan.getCanonicalIV()->getScalarType());
1740-
runPass(simplifyBranchOnCondTrue, Plan);
1740+
runPass(removeBranchOnCondTrue, Plan);
17411741
runPass(removeDeadRecipes, Plan);
17421742

17431743
runPass(createAndOptimizeReplicateRegions, Plan);

0 commit comments

Comments
 (0)