Skip to content

Commit bc7487d

Browse files
committed
[VPlan] Cast header and latch to VPBasicBlock early (NFC).
There are only VPBasicBlocks when prepareForVectorization is called. Cast them early instead of having multiple casts later on.
1 parent a7c9563 commit bc7487d

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -466,28 +466,27 @@ void VPlanTransforms::prepareForVectorization(
466466
VPDominatorTree VPDT;
467467
VPDT.recalculate(Plan);
468468

469-
VPBlockBase *HeaderVPB = Plan.getEntry()->getSingleSuccessor();
470-
canonicalHeaderAndLatch(HeaderVPB, VPDT);
471-
VPBlockBase *LatchVPB = HeaderVPB->getPredecessors()[1];
469+
auto *HeaderVPBB = cast<VPBasicBlock>(Plan.getEntry()->getSingleSuccessor());
470+
canonicalHeaderAndLatch(HeaderVPBB, VPDT);
471+
auto *LatchVPBB = cast<VPBasicBlock>(HeaderVPBB->getPredecessors()[1]);
472472

473473
VPBasicBlock *VecPreheader = Plan.createVPBasicBlock("vector.ph");
474474
VPBlockUtils::insertBlockAfter(VecPreheader, Plan.getEntry());
475475

476476
VPBasicBlock *MiddleVPBB = Plan.createVPBasicBlock("middle.block");
477-
// The canonical LatchVPB has the header block as last successor. If it has
477+
// The canonical LatchVPBB has the header block as last successor. If it has
478478
// another successor, this successor is an exit block - insert middle block on
479479
// its edge. Otherwise, add middle block as another successor retaining header
480480
// as last.
481-
if (LatchVPB->getNumSuccessors() == 2) {
482-
VPBlockBase *LatchExitVPB = LatchVPB->getSuccessors()[0];
483-
VPBlockUtils::insertOnEdge(LatchVPB, LatchExitVPB, MiddleVPBB);
481+
if (LatchVPBB->getNumSuccessors() == 2) {
482+
VPBlockBase *LatchExitVPB = LatchVPBB->getSuccessors()[0];
483+
VPBlockUtils::insertOnEdge(LatchVPBB, LatchExitVPB, MiddleVPBB);
484484
} else {
485-
VPBlockUtils::connectBlocks(LatchVPB, MiddleVPBB);
486-
LatchVPB->swapSuccessors();
485+
VPBlockUtils::connectBlocks(LatchVPBB, MiddleVPBB);
486+
LatchVPBB->swapSuccessors();
487487
}
488488

489-
addCanonicalIVRecipes(Plan, cast<VPBasicBlock>(HeaderVPB),
490-
cast<VPBasicBlock>(LatchVPB), InductionTy, IVDL);
489+
addCanonicalIVRecipes(Plan, HeaderVPBB, LatchVPBB, InductionTy, IVDL);
491490

492491
[[maybe_unused]] bool HandledUncountableEarlyExit = false;
493492
// Disconnect all early exits from the loop leaving it with a single exit from
@@ -503,8 +502,7 @@ void VPlanTransforms::prepareForVectorization(
503502
assert(!HandledUncountableEarlyExit &&
504503
"can handle exactly one uncountable early exit");
505504
handleUncountableEarlyExit(cast<VPBasicBlock>(Pred), EB, Plan,
506-
cast<VPBasicBlock>(HeaderVPB),
507-
cast<VPBasicBlock>(LatchVPB), Range);
505+
HeaderVPBB, LatchVPBB, Range);
508506
HandledUncountableEarlyExit = true;
509507
} else {
510508
for (VPRecipeBase &R : EB->phis())

0 commit comments

Comments
 (0)