Skip to content

Commit c56cdcd

Browse files
committed
[LV] Add a statistic for early exit vectorization
We currently do not vectorize the epilog loops with early-exits, but the stats are updated there as well for completeness.
1 parent c92b580 commit c56cdcd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ const char LLVMLoopVectorizeFollowupEpilogue[] =
175175
STATISTIC(LoopsVectorized, "Number of loops vectorized");
176176
STATISTIC(LoopsAnalyzed, "Number of loops analyzed for vectorization");
177177
STATISTIC(LoopsEpilogueVectorized, "Number of epilogues vectorized");
178+
STATISTIC(LoopsEarlyExitVectorized, "Number of early exit loops vectorized");
179+
178180

179181
static cl::opt<bool> EnableEpilogueVectorization(
180182
"enable-epilogue-vectorization", cl::init(true), cl::Hidden,
@@ -10291,6 +10293,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1029110293
auto ExpandedSCEVs = LVP.executePlan(EPI.MainLoopVF, EPI.MainLoopUF,
1029210294
*BestMainPlan, MainILV, DT, false);
1029310295
++LoopsVectorized;
10296+
// TODO: Currently unsupported for early exits.
10297+
if (BestPlan.hasEarlyExit())
10298+
++LoopsEarlyExitVectorized;
1029410299

1029510300
// Second pass vectorizes the epilogue and adjusts the control flow
1029610301
// edges from the first pass.
@@ -10319,6 +10324,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1031910324
Inc->setIncomingValueForBlock(BypassBlock, V);
1032010325
}
1032110326
++LoopsEpilogueVectorized;
10327+
// TODO: Currently unsupported for early exits.
10328+
if (BestEpiPlan.hasEarlyExit())
10329+
++LoopsEarlyExitVectorized;
10330+
1032210331

1032310332
if (!Checks.hasChecks())
1032410333
DisableRuntimeUnroll = true;
@@ -10328,6 +10337,8 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1032810337
Checks, BestPlan);
1032910338
LVP.executePlan(VF.Width, IC, BestPlan, LB, DT, false);
1033010339
++LoopsVectorized;
10340+
if (BestPlan.hasEarlyExit())
10341+
++LoopsEarlyExitVectorized;
1033110342

1033210343
// Add metadata to disable runtime unrolling a scalar loop when there
1033310344
// are no runtime checks about strides and memory. A scalar loop that is

0 commit comments

Comments
 (0)