@@ -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
@@ -7649,8 +7659,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7649
7659
7650
7660
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
7651
7661
// 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 ());
7654
7664
VPlanTransforms::optimizeForVFAndUF (BestVPlan, BestVF, BestUF, PSE);
7655
7665
VPlanTransforms::convertToConcreteRecipes (BestVPlan);
7656
7666
@@ -8887,13 +8897,14 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
8887
8897
if (auto Plan = tryToBuildVPlanWithVPRecipes (SubRange)) {
8888
8898
// Now optimize the initial VPlan.
8889
8899
if (!Plan->hasVF (ElementCount::getFixed (1 )))
8890
- VPlanTransforms::truncateToMinimalBitwidths (*Plan ,
8891
- CM.getMinimalBitwidths ());
8900
+ VPlanTransforms::runPass (VPlanTransforms::truncateToMinimalBitwidths ,
8901
+ *Plan, CM.getMinimalBitwidths ());
8892
8902
VPlanTransforms::optimize (*Plan);
8893
8903
// TODO: try to put it close to addActiveLaneMask().
8894
8904
// 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 ()))
8897
8908
break ;
8898
8909
assert (verifyVPlanIsValid (*Plan) && " VPlan is invalid" );
8899
8910
VPlans.push_back (std::move (Plan));
@@ -9393,8 +9404,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9393
9404
9394
9405
if (auto *UncountableExitingBlock =
9395
9406
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);
9398
9410
}
9399
9411
DenseMap<VPValue *, VPValue *> IVEndValues;
9400
9412
addScalarResumePhis (RecipeBuilder, *Plan, IVEndValues);
@@ -9419,8 +9431,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9419
9431
// Interleave memory: for each Interleave Group we marked earlier as relevant
9420
9432
// for this VPlan, replace the Recipes widening its memory instructions with a
9421
9433
// 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 ());
9424
9437
9425
9438
for (ElementCount VF : Range)
9426
9439
Plan->addVF (VF);
@@ -9462,13 +9475,16 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9462
9475
}
9463
9476
}
9464
9477
9465
- VPlanTransforms::dropPoisonGeneratingRecipes (*Plan, [this ](BasicBlock *BB) {
9478
+ auto BlockNeedsPredication = [this ](BasicBlock *BB) {
9466
9479
return Legal->blockNeedsPredication (BB);
9467
- });
9480
+ };
9481
+ VPlanTransforms::runPass (VPlanTransforms::dropPoisonGeneratingRecipes, *Plan,
9482
+ BlockNeedsPredication);
9468
9483
9469
9484
// Sink users of fixed-order recurrence past the recipe defining the previous
9470
9485
// value and introduce FirstOrderRecurrenceSplice VPInstructions.
9471
- if (!VPlanTransforms::adjustFixedOrderRecurrences (*Plan, Builder))
9486
+ if (!VPlanTransforms::runPass (VPlanTransforms::adjustFixedOrderRecurrences,
9487
+ *Plan, Builder))
9472
9488
return nullptr ;
9473
9489
9474
9490
if (useActiveLaneMask (Style)) {
@@ -9817,10 +9833,10 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9817
9833
PhiR->setOperand (0 , Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ()));
9818
9834
}
9819
9835
}
9820
-
9821
- VPlanTransforms::clearReductionWrapFlags (*Plan);
9822
9836
for (VPRecipeBase *R : ToDelete)
9823
9837
R->eraseFromParent ();
9838
+
9839
+ VPlanTransforms::runPass (VPlanTransforms::clearReductionWrapFlags, *Plan);
9824
9840
}
9825
9841
9826
9842
void VPDerivedIVRecipe::execute (VPTransformState &State) {
@@ -10184,7 +10200,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
10184
10200
VPIRInst->eraseFromParent ();
10185
10201
ResumePhi->eraseFromParent ();
10186
10202
}
10187
- VPlanTransforms::removeDeadRecipes ( MainPlan);
10203
+ VPlanTransforms::runPass (VPlanTransforms::removeDeadRecipes, MainPlan);
10188
10204
10189
10205
using namespace VPlanPatternMatch ;
10190
10206
VPBasicBlock *MainScalarPH = MainPlan.getScalarPreheader ();
0 commit comments