@@ -355,6 +355,16 @@ cl::opt<bool> EnableVPlanNativePath(
355355 " enable-vplan-native-path" , cl::Hidden,
356356 cl::desc (" Enable VPlan-native vectorization path with "
357357 " support for outer loop vectorization." ));
358+
359+ cl::opt<bool >
360+ VerifyEachVPlan (" vplan-verify-each" ,
361+ #ifdef EXPENSIVE_CHECKS
362+ cl::init (true ),
363+ #else
364+ cl::init (false ),
365+ #endif
366+ cl::Hidden,
367+ cl::desc (" Verfiy VPlans after VPlan transforms." ));
358368} // namespace llvm
359369
360370// This flag enables the stress testing of the VPlan H-CFG construction in the
@@ -7651,8 +7661,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
76517661
76527662 // TODO: Move to VPlan transform stage once the transition to the VPlan-based
76537663 // cost model is complete for better cost estimates.
7654- VPlanTransforms::unrollByUF ( BestVPlan, BestUF,
7655- OrigLoop->getHeader ()->getContext ());
7664+ VPlanTransforms::runPass (VPlanTransforms::unrollByUF, BestVPlan, BestUF,
7665+ OrigLoop->getHeader ()->getContext ());
76567666 VPlanTransforms::optimizeForVFAndUF (BestVPlan, BestVF, BestUF, PSE);
76577667 VPlanTransforms::convertToConcreteRecipes (BestVPlan);
76587668
@@ -8908,13 +8918,14 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
89088918 if (auto Plan = tryToBuildVPlanWithVPRecipes (SubRange)) {
89098919 // Now optimize the initial VPlan.
89108920 if (!Plan->hasVF (ElementCount::getFixed (1 )))
8911- VPlanTransforms::truncateToMinimalBitwidths (*Plan ,
8912- CM.getMinimalBitwidths ());
8921+ VPlanTransforms::runPass (VPlanTransforms::truncateToMinimalBitwidths ,
8922+ *Plan, CM.getMinimalBitwidths ());
89138923 VPlanTransforms::optimize (*Plan);
89148924 // TODO: try to put it close to addActiveLaneMask().
89158925 // Discard the plan if it is not EVL-compatible
8916- if (CM.foldTailWithEVL () && !VPlanTransforms::tryAddExplicitVectorLength (
8917- *Plan, CM.getMaxSafeElements ()))
8926+ if (CM.foldTailWithEVL () &&
8927+ !VPlanTransforms::runPass (VPlanTransforms::tryAddExplicitVectorLength,
8928+ *Plan, CM.getMaxSafeElements ()))
89188929 break ;
89198930 assert (verifyVPlanIsValid (*Plan) && " VPlan is invalid" );
89208931 VPlans.push_back (std::move (Plan));
@@ -9423,8 +9434,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94239434 // Interleave memory: for each Interleave Group we marked earlier as relevant
94249435 // for this VPlan, replace the Recipes widening its memory instructions with a
94259436 // single VPInterleaveRecipe at its insertion point.
9426- VPlanTransforms::createInterleaveGroups (
9427- *Plan, InterleaveGroups, RecipeBuilder, CM.isScalarEpilogueAllowed ());
9437+ VPlanTransforms::runPass (VPlanTransforms::createInterleaveGroups, *Plan,
9438+ InterleaveGroups, RecipeBuilder,
9439+ CM.isScalarEpilogueAllowed ());
94289440
94299441 for (ElementCount VF : Range)
94309442 Plan->addVF (VF);
@@ -9466,13 +9478,16 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94669478 }
94679479 }
94689480
9469- VPlanTransforms::dropPoisonGeneratingRecipes (*Plan, [this ](BasicBlock *BB) {
9481+ auto BlockNeedsPredication = [this ](BasicBlock *BB) {
94709482 return Legal->blockNeedsPredication (BB);
9471- });
9483+ };
9484+ VPlanTransforms::runPass (VPlanTransforms::dropPoisonGeneratingRecipes, *Plan,
9485+ BlockNeedsPredication);
94729486
94739487 // Sink users of fixed-order recurrence past the recipe defining the previous
94749488 // value and introduce FirstOrderRecurrenceSplice VPInstructions.
9475- if (!VPlanTransforms::adjustFixedOrderRecurrences (*Plan, Builder))
9489+ if (!VPlanTransforms::runPass (VPlanTransforms::adjustFixedOrderRecurrences,
9490+ *Plan, Builder))
94769491 return nullptr ;
94779492
94789493 if (useActiveLaneMask (Style)) {
@@ -9815,10 +9830,10 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
98159830 PhiR->setOperand (0 , Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ()));
98169831 }
98179832 }
9818-
9819- VPlanTransforms::clearReductionWrapFlags (*Plan);
98209833 for (VPRecipeBase *R : ToDelete)
98219834 R->eraseFromParent ();
9835+
9836+ VPlanTransforms::runPass (VPlanTransforms::clearReductionWrapFlags, *Plan);
98229837}
98239838
98249839void VPDerivedIVRecipe::execute (VPTransformState &State) {
@@ -10182,7 +10197,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
1018210197 VPIRInst->eraseFromParent ();
1018310198 ResumePhi->eraseFromParent ();
1018410199 }
10185- VPlanTransforms::removeDeadRecipes ( MainPlan);
10200+ VPlanTransforms::runPass (VPlanTransforms::removeDeadRecipes, MainPlan);
1018610201
1018710202 using namespace VPlanPatternMatch ;
1018810203 VPBasicBlock *MainScalarPH = MainPlan.getScalarPreheader ();
0 commit comments