@@ -355,6 +355,16 @@ cl::opt<bool> EnableVPlanNativePath(
355
355
" enable-vplan-native-path" , cl::Hidden,
356
356
cl::desc (" Enable VPlan-native vectorization path with "
357
357
" 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." ));
358
368
} // namespace llvm
359
369
360
370
// This flag enables the stress testing of the VPlan H-CFG construction in the
@@ -7651,8 +7661,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7651
7661
7652
7662
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
7653
7663
// 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 ());
7656
7666
VPlanTransforms::optimizeForVFAndUF (BestVPlan, BestVF, BestUF, PSE);
7657
7667
VPlanTransforms::convertToConcreteRecipes (BestVPlan);
7658
7668
@@ -8908,13 +8918,14 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
8908
8918
if (auto Plan = tryToBuildVPlanWithVPRecipes (SubRange)) {
8909
8919
// Now optimize the initial VPlan.
8910
8920
if (!Plan->hasVF (ElementCount::getFixed (1 )))
8911
- VPlanTransforms::truncateToMinimalBitwidths (*Plan ,
8912
- CM.getMinimalBitwidths ());
8921
+ VPlanTransforms::runPass (VPlanTransforms::truncateToMinimalBitwidths ,
8922
+ *Plan, CM.getMinimalBitwidths ());
8913
8923
VPlanTransforms::optimize (*Plan);
8914
8924
// TODO: try to put it close to addActiveLaneMask().
8915
8925
// 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 ()))
8918
8929
break ;
8919
8930
assert (verifyVPlanIsValid (*Plan) && " VPlan is invalid" );
8920
8931
VPlans.push_back (std::move (Plan));
@@ -9423,8 +9434,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9423
9434
// Interleave memory: for each Interleave Group we marked earlier as relevant
9424
9435
// for this VPlan, replace the Recipes widening its memory instructions with a
9425
9436
// 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 ());
9428
9440
9429
9441
for (ElementCount VF : Range)
9430
9442
Plan->addVF (VF);
@@ -9466,13 +9478,16 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9466
9478
}
9467
9479
}
9468
9480
9469
- VPlanTransforms::dropPoisonGeneratingRecipes (*Plan, [this ](BasicBlock *BB) {
9481
+ auto BlockNeedsPredication = [this ](BasicBlock *BB) {
9470
9482
return Legal->blockNeedsPredication (BB);
9471
- });
9483
+ };
9484
+ VPlanTransforms::runPass (VPlanTransforms::dropPoisonGeneratingRecipes, *Plan,
9485
+ BlockNeedsPredication);
9472
9486
9473
9487
// Sink users of fixed-order recurrence past the recipe defining the previous
9474
9488
// value and introduce FirstOrderRecurrenceSplice VPInstructions.
9475
- if (!VPlanTransforms::adjustFixedOrderRecurrences (*Plan, Builder))
9489
+ if (!VPlanTransforms::runPass (VPlanTransforms::adjustFixedOrderRecurrences,
9490
+ *Plan, Builder))
9476
9491
return nullptr ;
9477
9492
9478
9493
if (useActiveLaneMask (Style)) {
@@ -9815,10 +9830,10 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9815
9830
PhiR->setOperand (0 , Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ()));
9816
9831
}
9817
9832
}
9818
-
9819
- VPlanTransforms::clearReductionWrapFlags (*Plan);
9820
9833
for (VPRecipeBase *R : ToDelete)
9821
9834
R->eraseFromParent ();
9835
+
9836
+ VPlanTransforms::runPass (VPlanTransforms::clearReductionWrapFlags, *Plan);
9822
9837
}
9823
9838
9824
9839
void VPDerivedIVRecipe::execute (VPTransformState &State) {
@@ -10182,7 +10197,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
10182
10197
VPIRInst->eraseFromParent ();
10183
10198
ResumePhi->eraseFromParent ();
10184
10199
}
10185
- VPlanTransforms::removeDeadRecipes ( MainPlan);
10200
+ VPlanTransforms::runPass (VPlanTransforms::removeDeadRecipes, MainPlan);
10186
10201
10187
10202
using namespace VPlanPatternMatch ;
10188
10203
VPBasicBlock *MainScalarPH = MainPlan.getScalarPreheader ();
0 commit comments