Skip to content

Commit 7293720

Browse files
committed
[VPlan] Create vector header and latch VPBBs in createInitialVPlan (NFC)
The empty header and latch blocks can be created together with the vector loop region. This is in preparation for splitting up the very large tryToBuildVPlanWithVPRecipes into several distinct functions, as suggested multiple times, including in #94760
1 parent 72ccdd8 commit 7293720

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8548,11 +8548,6 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
85488548
createTripCountSCEV(Legal->getWidestInductionType(), PSE, OrigLoop),
85498549
*PSE.getSE(), RequiresScalarEpilogueCheck, CM.foldTailByMasking(),
85508550
OrigLoop);
8551-
VPBasicBlock *HeaderVPBB = new VPBasicBlock("vector.body");
8552-
VPBasicBlock *LatchVPBB = new VPBasicBlock("vector.latch");
8553-
VPBlockUtils::insertBlockAfter(LatchVPBB, HeaderVPBB);
8554-
Plan->getVectorLoopRegion()->setEntry(HeaderVPBB);
8555-
Plan->getVectorLoopRegion()->setExiting(LatchVPBB);
85568551

85578552
// Don't use getDecisionAndClampRange here, because we don't know the UF
85588553
// so this function is better to be conservative, rather than to split
@@ -8606,6 +8601,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
86068601
LoopBlocksDFS DFS(OrigLoop);
86078602
DFS.perform(LI);
86088603

8604+
VPBasicBlock *HeaderVPBB = Plan->getVectorLoopRegion()->getEntryBasicBlock();
86098605
VPBasicBlock *VPBB = HeaderVPBB;
86108606
BasicBlock *HeaderBB = OrigLoop->getHeader();
86118607
bool NeedsMasks =

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,14 @@ VPlanPtr VPlan::createInitialVPlan(const SCEV *TripCount, ScalarEvolution &SE,
820820
auto Plan = std::make_unique<VPlan>(Entry, VecPreheader);
821821
Plan->TripCount =
822822
vputils::getOrCreateVPValueForSCEVExpr(*Plan, TripCount, SE);
823-
// Create empty VPRegionBlock, to be filled during processing later.
824-
auto *TopRegion = new VPRegionBlock("vector loop", false /*isReplicator*/);
823+
// Create VPRegionBlock, with empty header and latch blocks, to be filled
824+
// during processing later.
825+
VPBasicBlock *HeaderVPBB = new VPBasicBlock("vector.body");
826+
VPBasicBlock *LatchVPBB = new VPBasicBlock("vector.latch");
827+
VPBlockUtils::insertBlockAfter(LatchVPBB, HeaderVPBB);
828+
auto *TopRegion = new VPRegionBlock(HeaderVPBB, LatchVPBB, "vector loop",
829+
false /*isReplicator*/);
830+
825831
VPBlockUtils::insertBlockAfter(TopRegion, VecPreheader);
826832
VPBasicBlock *MiddleVPBB = new VPBasicBlock("middle.block");
827833
VPBlockUtils::insertBlockAfter(MiddleVPBB, TopRegion);

0 commit comments

Comments
 (0)