@@ -175,6 +175,7 @@ const char LLVMLoopVectorizeFollowupEpilogue[] =
175
175
STATISTIC (LoopsVectorized, " Number of loops vectorized" );
176
176
STATISTIC (LoopsAnalyzed, " Number of loops analyzed for vectorization" );
177
177
STATISTIC (LoopsEpilogueVectorized, " Number of epilogues vectorized" );
178
+ STATISTIC (LoopsEarlyExitVectorized, " Number of early exit loops vectorized" );
178
179
179
180
static cl::opt<bool > EnableEpilogueVectorization (
180
181
" enable-epilogue-vectorization" , cl::init(true ), cl::Hidden,
@@ -7324,6 +7325,11 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7324
7325
" Trying to execute plan with unsupported VF" );
7325
7326
assert (BestVPlan.hasUF (BestUF) &&
7326
7327
" Trying to execute plan with unsupported UF" );
7328
+ ++LoopsVectorized;
7329
+ if (BestVPlan.hasEarlyExit ())
7330
+ ++LoopsEarlyExitVectorized;
7331
+ if (VectorizingEpilogue)
7332
+ ++LoopsEpilogueVectorized;
7327
7333
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
7328
7334
// cost model is complete for better cost estimates.
7329
7335
VPlanTransforms::runPass (VPlanTransforms::unrollByUF, BestVPlan, BestUF,
@@ -10259,7 +10265,8 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10259
10265
L, PSE, LI, DT, TLI, TTI, AC, ORE, ElementCount::getFixed (1 ),
10260
10266
ElementCount::getFixed (1 ), IC, &CM, BFI, PSI, Checks, BestPlan);
10261
10267
10262
- LVP.executePlan (VF.Width , IC, BestPlan, Unroller, DT, false );
10268
+ LVP.executePlan (VF.Width , IC, BestPlan, Unroller, DT,
10269
+ /* VectorizingEpilogue*/ false );
10263
10270
10264
10271
ORE->emit ([&]() {
10265
10272
return OptimizationRemark (LV_NAME, " Interleaved" , L->getStartLoc (),
@@ -10288,9 +10295,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10288
10295
EpilogueVectorizerMainLoop MainILV (L, PSE, LI, DT, TLI, TTI, AC, ORE,
10289
10296
EPI, &CM, BFI, PSI, Checks,
10290
10297
*BestMainPlan);
10291
- auto ExpandedSCEVs = LVP. executePlan (EPI. MainLoopVF , EPI. MainLoopUF ,
10292
- *BestMainPlan, MainILV, DT, false );
10293
- ++LoopsVectorized ;
10298
+ auto ExpandedSCEVs =
10299
+ LVP. executePlan (EPI. MainLoopVF , EPI. MainLoopUF , *BestMainPlan,
10300
+ MainILV, DT, /* VectorizingEpilogue */ false ) ;
10294
10301
10295
10302
// Second pass vectorizes the epilogue and adjusts the control flow
10296
10303
// edges from the first pass.
@@ -10303,7 +10310,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10303
10310
preparePlanForEpilogueVectorLoop (BestEpiPlan, L, ExpandedSCEVs, EPI);
10304
10311
10305
10312
LVP.executePlan (EPI.EpilogueVF , EPI.EpilogueUF , BestEpiPlan, EpilogILV,
10306
- DT, true );
10313
+ DT, /* VectorizingEpilogue */ true );
10307
10314
10308
10315
// Fix induction resume values from the additional bypass block.
10309
10316
BasicBlock *BypassBlock = EpilogILV.getAdditionalBypassBlock ();
@@ -10318,7 +10325,6 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10318
10325
// TODO: Directly add as extra operand to the VPResumePHI recipe.
10319
10326
Inc->setIncomingValueForBlock (BypassBlock, V);
10320
10327
}
10321
- ++LoopsEpilogueVectorized;
10322
10328
10323
10329
if (!Checks.hasChecks ())
10324
10330
DisableRuntimeUnroll = true ;
@@ -10327,7 +10333,6 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10327
10333
VF.MinProfitableTripCount , IC, &CM, BFI, PSI,
10328
10334
Checks, BestPlan);
10329
10335
LVP.executePlan (VF.Width , IC, BestPlan, LB, DT, false );
10330
- ++LoopsVectorized;
10331
10336
10332
10337
// Add metadata to disable runtime unrolling a scalar loop when there
10333
10338
// are no runtime checks about strides and memory. A scalar loop that is
0 commit comments