[llvm] df7a21f - [LV] Remove EpilogueLoopVectorizationInfo::EpilogueUF (NFC). (#226792)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 27 14:29:57 PDT 2026
Author: Florian Hahn
Date: 2026-09-27T22:29:51+01:00
New Revision: df7a21f8210426653d12c50475651c4d7518b804
URL: https://github.com/llvm/llvm-project/commit/df7a21f8210426653d12c50475651c4d7518b804
DIFF: https://github.com/llvm/llvm-project/commit/df7a21f8210426653d12c50475651c4d7518b804.diff
LOG: [LV] Remove EpilogueLoopVectorizationInfo::EpilogueUF (NFC). (#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.
Clean-up in preparation for removing/simplifying
EpilogueLoopVectorizationInfo.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
llvm/lib/Transforms/Vectorize/VPlanTransforms.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index e934fec366331..1c2372483e356 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";
});
}
@@ -6028,8 +6024,7 @@ BasicBlock *EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton() {
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 VF:" << EPI.EpilogueVF << ", Epilogue Loop UF:1\n";
});
}
@@ -7594,12 +7589,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,
- SE);
+ EPI.EpilogueVF, MainLoopStep, EpilogueLoopStep, SE);
return InstsToMove;
}
@@ -8128,11 +8121,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 +8154,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