@@ -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
@@ -7649,8 +7659,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
76497659
76507660 // TODO: Move to VPlan transform stage once the transition to the VPlan-based
76517661 // cost model is complete for better cost estimates.
7652- VPlanTransforms::unrollByUF ( BestVPlan, BestUF,
7653- OrigLoop->getHeader ()->getContext ());
7662+ VPlanTransforms::runPass (VPlanTransforms::unrollByUF, BestVPlan, BestUF,
7663+ OrigLoop->getHeader ()->getContext ());
76547664 VPlanTransforms::optimizeForVFAndUF (BestVPlan, BestVF, BestUF, PSE);
76557665 VPlanTransforms::convertToConcreteRecipes (BestVPlan);
76567666
@@ -8887,13 +8897,14 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
88878897 if (auto Plan = tryToBuildVPlanWithVPRecipes (SubRange)) {
88888898 // Now optimize the initial VPlan.
88898899 if (!Plan->hasVF (ElementCount::getFixed (1 )))
8890- VPlanTransforms::truncateToMinimalBitwidths (*Plan ,
8891- CM.getMinimalBitwidths ());
8900+ VPlanTransforms::runPass (VPlanTransforms::truncateToMinimalBitwidths ,
8901+ *Plan, CM.getMinimalBitwidths ());
88928902 VPlanTransforms::optimize (*Plan);
88938903 // TODO: try to put it close to addActiveLaneMask().
88948904 // Discard the plan if it is not EVL-compatible
8895- if (CM.foldTailWithEVL () && !VPlanTransforms::tryAddExplicitVectorLength (
8896- *Plan, CM.getMaxSafeElements ()))
8905+ if (CM.foldTailWithEVL () &&
8906+ !VPlanTransforms::runPass (VPlanTransforms::tryAddExplicitVectorLength,
8907+ *Plan, CM.getMaxSafeElements ()))
88978908 break ;
88988909 assert (verifyVPlanIsValid (*Plan) && " VPlan is invalid" );
88998910 VPlans.push_back (std::move (Plan));
@@ -9393,8 +9404,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
93939404
93949405 if (auto *UncountableExitingBlock =
93959406 Legal->getUncountableEarlyExitingBlock ()) {
9396- VPlanTransforms::handleUncountableEarlyExit (
9397- *Plan, *PSE.getSE (), OrigLoop, UncountableExitingBlock, RecipeBuilder);
9407+ VPlanTransforms::runPass (VPlanTransforms::handleUncountableEarlyExit, *Plan,
9408+ *PSE.getSE (), OrigLoop, UncountableExitingBlock,
9409+ RecipeBuilder);
93989410 }
93999411 DenseMap<VPValue *, VPValue *> IVEndValues;
94009412 addScalarResumePhis (RecipeBuilder, *Plan, IVEndValues);
@@ -9419,8 +9431,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94199431 // Interleave memory: for each Interleave Group we marked earlier as relevant
94209432 // for this VPlan, replace the Recipes widening its memory instructions with a
94219433 // single VPInterleaveRecipe at its insertion point.
9422- VPlanTransforms::createInterleaveGroups (
9423- *Plan, InterleaveGroups, RecipeBuilder, CM.isScalarEpilogueAllowed ());
9434+ VPlanTransforms::runPass (VPlanTransforms::createInterleaveGroups, *Plan,
9435+ InterleaveGroups, RecipeBuilder,
9436+ CM.isScalarEpilogueAllowed ());
94249437
94259438 for (ElementCount VF : Range)
94269439 Plan->addVF (VF);
@@ -9462,13 +9475,16 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94629475 }
94639476 }
94649477
9465- VPlanTransforms::dropPoisonGeneratingRecipes (*Plan, [this ](BasicBlock *BB) {
9478+ auto BlockNeedsPredication = [this ](BasicBlock *BB) {
94669479 return Legal->blockNeedsPredication (BB);
9467- });
9480+ };
9481+ VPlanTransforms::runPass (VPlanTransforms::dropPoisonGeneratingRecipes, *Plan,
9482+ BlockNeedsPredication);
94689483
94699484 // Sink users of fixed-order recurrence past the recipe defining the previous
94709485 // value and introduce FirstOrderRecurrenceSplice VPInstructions.
9471- if (!VPlanTransforms::adjustFixedOrderRecurrences (*Plan, Builder))
9486+ if (!VPlanTransforms::runPass (VPlanTransforms::adjustFixedOrderRecurrences,
9487+ *Plan, Builder))
94729488 return nullptr ;
94739489
94749490 if (useActiveLaneMask (Style)) {
@@ -9817,10 +9833,10 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
98179833 PhiR->setOperand (0 , Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ()));
98189834 }
98199835 }
9820-
9821- VPlanTransforms::clearReductionWrapFlags (*Plan);
98229836 for (VPRecipeBase *R : ToDelete)
98239837 R->eraseFromParent ();
9838+
9839+ VPlanTransforms::runPass (VPlanTransforms::clearReductionWrapFlags, *Plan);
98249840}
98259841
98269842void VPDerivedIVRecipe::execute (VPTransformState &State) {
@@ -10184,7 +10200,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
1018410200 VPIRInst->eraseFromParent ();
1018510201 ResumePhi->eraseFromParent ();
1018610202 }
10187- VPlanTransforms::removeDeadRecipes ( MainPlan);
10203+ VPlanTransforms::runPass (VPlanTransforms::removeDeadRecipes, MainPlan);
1018810204
1018910205 using namespace VPlanPatternMatch ;
1019010206 VPBasicBlock *MainScalarPH = MainPlan.getScalarPreheader ();
0 commit comments