[llvm] [LV] Remove EpilogueLoopVectorizationInfo::EpilogueUF (NFC). (PR #226792)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 27 07:39:00 PDT 2026
https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/226792
The epilogue vector loop is always unrolled by 1: the only construction site passes 1 and the constructor asserted it. Drop the field and use 1 directly at its users, and drop the now always 1 EpilogueUF parameter of addMinimumVectorEpilogueIterationCheck.
>From 443dcaf248eace59f28205cd0386530a2e10a08f Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Fri, 11 Sep 2026 16:05:58 +0100
Subject: [PATCH] [LV] Remove EpilogueLoopVectorizationInfo::EpilogueUF (NFC).
The epilogue vector loop is always unrolled by 1: the only construction
site passes 1 and the constructor asserted it. Drop the field and use 1
directly at its users, and drop the now always 1 EpilogueUF parameter of
addMinimumVectorEpilogueIterationCheck.
---
.../Transforms/Vectorize/LoopVectorize.cpp | 25 ++++++++-----------
.../Vectorize/VPlanConstruction.cpp | 8 +++---
.../Transforms/Vectorize/VPlanTransforms.h | 4 +--
3 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index e934fec366331..57740f9d2ef68 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -629,15 +629,11 @@ struct EpilogueLoopVectorizationInfo {
ElementCount MainLoopVF = ElementCount::getFixed(0);
unsigned MainLoopUF = 0;
ElementCount EpilogueVF = ElementCount::getFixed(0);
- unsigned EpilogueUF = 0;
Value *VectorTripCount = nullptr;
EpilogueLoopVectorizationInfo(ElementCount MVF, unsigned MUF,
- ElementCount EVF, unsigned EUF)
- : MainLoopVF(MVF), MainLoopUF(MUF), EpilogueVF(EVF), EpilogueUF(EUF) {
- assert(EUF == 1 &&
- "A high UF for the epilogue loop is likely not beneficial.");
- }
+ ElementCount EVF)
+ : MainLoopVF(MVF), MainLoopUF(MUF), EpilogueVF(EVF) {}
};
/// An extension of the inner loop vectorizer that creates a skeleton for a
@@ -707,7 +703,7 @@ class EpilogueVectorizerEpilogueLoop : public InnerLoopAndEpilogueVectorizer {
VPlan &MainPlan)
: InnerLoopAndEpilogueVectorizer(OrigLoop, PSE, LI, DT, TTI, AC, EPI,
Checks, Plan, EPI.EpilogueVF,
- EPI.EpilogueUF),
+ /*UnrollFactor=*/1),
MainPlan(MainPlan) {}
/// Implements the interface for creating a vectorized skeleton using the
/// *epilogue loop* strategy (i.e., the second pass of VPlan execution).
@@ -5982,7 +5978,7 @@ void EpilogueVectorizerMainLoop::printDebugTracesAtStart() {
<< "Main Loop VF:" << EPI.MainLoopVF
<< ", Main Loop UF:" << EPI.MainLoopUF
<< ", Epilogue Loop VF:" << EPI.EpilogueVF
- << ", Epilogue Loop UF:" << EPI.EpilogueUF << "\n";
+ << ", Epilogue Loop UF:1\n";
});
}
@@ -6029,7 +6025,7 @@ void EpilogueVectorizerEpilogueLoop::printDebugTracesAtStart() {
LLVM_DEBUG({
dbgs() << "Create Skeleton for epilogue vectorized loop (second pass)\n"
<< "Epilogue Loop VF:" << EPI.EpilogueVF
- << ", Epilogue Loop UF:" << EPI.EpilogueUF << "\n";
+ << ", Epilogue Loop UF:1\n";
});
}
@@ -7594,11 +7590,10 @@ static SmallVector<Instruction *> preparePlanForEpilogueVectorLoop(
auto VScale = Config.getVScaleForTuning();
unsigned MainLoopStep =
estimateElementCount(EPI.MainLoopVF * EPI.MainLoopUF, VScale);
- unsigned EpilogueLoopStep =
- estimateElementCount(EPI.EpilogueVF * EPI.EpilogueUF, VScale);
+ unsigned EpilogueLoopStep = estimateElementCount(EPI.EpilogueVF, VScale);
RUN_VPLAN_PASS(VPlanTransforms::addMinimumVectorEpilogueIterationCheck, Plan,
EPI.VectorTripCount, Plan.requiresScalarEpilogue(),
- EPI.EpilogueVF, EPI.EpilogueUF, MainLoopStep, EpilogueLoopStep,
+ EPI.EpilogueVF, MainLoopStep, EpilogueLoopStep,
SE);
return InstsToMove;
@@ -8128,11 +8123,11 @@ bool LoopVectorizePass::processLoop(Loop *L) {
BestEpiPlan.getVectorPreheader()->setName("vec.epilog.ph");
SmallVector<VPInstruction *> ResumeValues =
preparePlanForMainVectorLoop(BestMainPlan, BestEpiPlan);
- EpilogueLoopVectorizationInfo EPI(VF.Width, IC, EpilogueVF, 1);
+ EpilogueLoopVectorizationInfo EPI(VF.Width, IC, EpilogueVF);
// Add minimum iteration check for the epilogue plan, followed by runtime
// checks for the main plan.
- LVP.addMinimumIterationCheck(BestMainPlan, EPI.EpilogueVF, EPI.EpilogueUF,
+ LVP.addMinimumIterationCheck(BestMainPlan, EPI.EpilogueVF, /*UF=*/1,
ElementCount::getFixed(0));
LVP.attachRuntimeChecks(BestMainPlan, Checks, HasBranchWeights);
RUN_VPLAN_PASS(
@@ -8161,7 +8156,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
*PSE.getSE(), ResumeValues);
RUN_VPLAN_PASS(VPlanTransforms::simplifyLiveInsWithSCEV, BestEpiPlan, PSE);
LVP.executePlan(
- EPI.EpilogueVF, EPI.EpilogueUF, BestEpiPlan, EpilogILV, DT,
+ EPI.EpilogueVF, /*BestUF=*/1, BestEpiPlan, EpilogILV, DT,
LoopVectorizationPlanner::EpilogueVectorizationKind::Epilogue);
connectEpilogueVectorLoop(BestEpiPlan, DT,
EpilogILV.VecEpilogueIterationCountCheck,
diff --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index 6c5f688835c15..8f462e937b00f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -1617,14 +1617,14 @@ void VPlanTransforms::addIterationCountCheckBlock(
void VPlanTransforms::addMinimumVectorEpilogueIterationCheck(
VPlan &Plan, Value *VectorTripCount, bool RequiresScalarEpilogue,
- ElementCount EpilogueVF, unsigned EpilogueUF, unsigned MainLoopStep,
- unsigned EpilogueLoopStep, ScalarEvolution &SE) {
+ ElementCount EpilogueVF, unsigned MainLoopStep, unsigned EpilogueLoopStep,
+ ScalarEvolution &SE) {
// Add the minimum iteration check for the epilogue vector loop.
VPValue *TC = Plan.getTripCount();
Value *TripCount = TC->getLiveInIRValue();
VPBuilder Builder(cast<VPBasicBlock>(Plan.getEntry()));
- VPValue *VFxUF = Builder.createExpandSCEV(SE.getElementCount(
- TripCount->getType(), (EpilogueVF * EpilogueUF), SCEV::FlagNUW));
+ VPValue *VFxUF = Builder.createExpandSCEV(
+ SE.getElementCount(TripCount->getType(), EpilogueVF, SCEV::FlagNUW));
VPValue *Count = Builder.createSub(TC, Plan.getOrAddLiveIn(VectorTripCount),
DebugLoc::getUnknown(), "n.vec.remaining");
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
index fd62693d6068b..d6fa21adb63e1 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
@@ -217,8 +217,8 @@ struct VPlanTransforms {
/// executed.
static void addMinimumVectorEpilogueIterationCheck(
VPlan &Plan, Value *VectorTripCount, bool RequiresScalarEpilogue,
- ElementCount EpilogueVF, unsigned EpilogueUF, unsigned MainLoopStep,
- unsigned EpilogueLoopStep, ScalarEvolution &SE);
+ ElementCount EpilogueVF, unsigned MainLoopStep, unsigned EpilogueLoopStep,
+ ScalarEvolution &SE);
/// Replace loops in \p Plan's flat CFG with VPRegionBlocks, turning \p Plan's
/// flat CFG into a hierarchical CFG. For the outermost loop, also create the
More information about the llvm-commits
mailing list