Skip to content

Commit 91b928f

Browse files
committed
[VPlan] Create header phis once regions have been created (NFC).
Since 1b29ac1, regions are constructed as part of the scalar transforms; moving header phi creation after region creation slightly simplifies the code.
1 parent 3dc46e9 commit 91b928f

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8045,16 +8045,17 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
80458045
OrigLoop, *LI, Legal->getWidestInductionType(),
80468046
getDebugLocFromInstOrOperands(Legal->getPrimaryInduction()), PSE, &LVer);
80478047

8048+
VPlanTransforms::simplifyRecipes(*VPlan0);
8049+
VPlanTransforms::handleEarlyExits(*VPlan0, Legal->hasUncountableEarlyExit());
8050+
VPlanTransforms::addMiddleCheck(*VPlan0, CM.foldTailByMasking());
8051+
RUN_VPLAN_PASS_NO_VERIFY(VPlanTransforms::createLoopRegions, *VPlan0);
8052+
80488053
// Create recipes for header phis.
80498054
VPlanTransforms::createHeaderPhiRecipes(
80508055
*VPlan0, PSE, *OrigLoop, Legal->getInductionVars(),
80518056
Legal->getReductionVars(), Legal->getFixedOrderRecurrences(),
80528057
CM.getInLoopReductions(), Hints.allowReordering());
80538058

8054-
VPlanTransforms::simplifyRecipes(*VPlan0);
8055-
VPlanTransforms::handleEarlyExits(*VPlan0, Legal->hasUncountableEarlyExit());
8056-
VPlanTransforms::addMiddleCheck(*VPlan0, CM.foldTailByMasking());
8057-
RUN_VPLAN_PASS_NO_VERIFY(VPlanTransforms::createLoopRegions, *VPlan0);
80588059
if (CM.foldTailByMasking())
80598060
RUN_VPLAN_PASS_NO_VERIFY(VPlanTransforms::foldTailByMasking, *VPlan0);
80608061
RUN_VPLAN_PASS_NO_VERIFY(VPlanTransforms::introduceMasksAndLinearize,
@@ -8345,17 +8346,18 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
83458346
OrigLoop, *LI, Legal->getWidestInductionType(),
83468347
getDebugLocFromInstOrOperands(Legal->getPrimaryInduction()), PSE);
83478348

8348-
VPlanTransforms::createHeaderPhiRecipes(
8349-
*Plan, PSE, *OrigLoop, Legal->getInductionVars(),
8350-
MapVector<PHINode *, RecurrenceDescriptor>(),
8351-
SmallPtrSet<const PHINode *, 1>(), SmallPtrSet<PHINode *, 1>(),
8352-
/*AllowReordering=*/false);
83538349
VPlanTransforms::handleEarlyExits(*Plan,
83548350
/*HasUncountableExit*/ false);
83558351
VPlanTransforms::addMiddleCheck(*Plan, /*TailFolded*/ false);
83568352

83578353
VPlanTransforms::createLoopRegions(*Plan);
83588354

8355+
VPlanTransforms::createHeaderPhiRecipes(
8356+
*Plan, PSE, *OrigLoop, Legal->getInductionVars(),
8357+
MapVector<PHINode *, RecurrenceDescriptor>(),
8358+
SmallPtrSet<const PHINode *, 1>(), SmallPtrSet<PHINode *, 1>(),
8359+
/*AllowReordering=*/false);
8360+
83598361
for (ElementCount VF : Range)
83608362
Plan->addVF(VF);
83618363

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,7 @@ void VPlanTransforms::createHeaderPhiRecipes(
702702
const MapVector<PHINode *, RecurrenceDescriptor> &Reductions,
703703
const SmallPtrSetImpl<const PHINode *> &FixedOrderRecurrences,
704704
const SmallPtrSetImpl<PHINode *> &InLoopReductions, bool AllowReordering) {
705-
// Retrieve the header manually from the intial plain-CFG VPlan.
706-
VPBasicBlock *HeaderVPBB = cast<VPBasicBlock>(
707-
Plan.getEntry()->getSuccessors()[1]->getSingleSuccessor());
708-
assert(VPDominatorTree(Plan).dominates(HeaderVPBB,
709-
HeaderVPBB->getPredecessors()[1]) &&
710-
"header must dominate its latch");
705+
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
711706

712707
auto CreateHeaderPhiRecipe = [&](VPPhi *PhiR) -> VPHeaderPHIRecipe * {
713708
// TODO: Gradually replace uses of underlying instruction by analyses on

0 commit comments

Comments
 (0)