Skip to content

Commit

Permalink
[LV] Pass flag indicating epilogue is vectorized to executePlan (NFC)
Browse files Browse the repository at this point in the history
This clarifies the flag, which is now only passed if the epilogue loop
is being vectorized.
  • Loading branch information
fhahn authored and pull[bot] committed Nov 15, 2024
1 parent 6a31cf5 commit 4987772
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ class LoopVectorizationPlanner {
/// Generate the IR code for the vectorized loop captured in VPlan \p BestPlan
/// according to the best selected \p VF and \p UF.
///
/// TODO: \p IsEpilogueVectorization is needed to avoid issues due to epilogue
/// vectorization re-using plans for both the main and epilogue vector loops.
/// It should be removed once the re-use issue has been fixed.
/// TODO: \p VectorizingEpilogue indicates if the executed VPlan is for the
/// epilogue vector loop. It should be removed once the re-use issue has been
/// fixed.
/// \p ExpandedSCEVs is passed during execution of the plan for epilogue loop
/// to re-use expansion results generated during main plan execution.
///
Expand All @@ -447,7 +447,7 @@ class LoopVectorizationPlanner {
DenseMap<const SCEV *, Value *>
executePlan(ElementCount VF, unsigned UF, VPlan &BestPlan,
InnerLoopVectorizer &LB, DominatorTree *DT,
bool IsEpilogueVectorization,
bool VectorizingEpilogue,
const DenseMap<const SCEV *, Value *> *ExpandedSCEVs = nullptr);

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7626,16 +7626,16 @@ static void createAndCollectMergePhiForReduction(

DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
ElementCount BestVF, unsigned BestUF, VPlan &BestVPlan,
InnerLoopVectorizer &ILV, DominatorTree *DT, bool IsEpilogueVectorization,
InnerLoopVectorizer &ILV, DominatorTree *DT, bool VectorizingEpilogue,
const DenseMap<const SCEV *, Value *> *ExpandedSCEVs) {
assert(BestVPlan.hasVF(BestVF) &&
"Trying to execute plan with unsupported VF");
assert(BestVPlan.hasUF(BestUF) &&
"Trying to execute plan with unsupported UF");
assert(
(IsEpilogueVectorization || !ExpandedSCEVs) &&
((VectorizingEpilogue && ExpandedSCEVs) ||
(!VectorizingEpilogue && !ExpandedSCEVs)) &&
"expanded SCEVs to reuse can only be used during epilogue vectorization");
(void)IsEpilogueVectorization;

// TODO: Move to VPlan transform stage once the transition to the VPlan-based
// cost model is complete for better cost estimates.
Expand All @@ -7661,8 +7661,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
if (!ILV.getTripCount())
ILV.setTripCount(State.get(BestVPlan.getTripCount(), VPLane(0)));
else
assert(IsEpilogueVectorization && "should only re-use the existing trip "
"count during epilogue vectorization");
assert(VectorizingEpilogue && "should only re-use the existing trip "
"count during epilogue vectorization");

// 1. Set up the skeleton for vectorization, including vector pre-header and
// middle block. The vector loop is created during VPlan execution.
Expand Down Expand Up @@ -7715,7 +7715,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
for (VPRecipeBase &R : *ExitVPBB) {
createAndCollectMergePhiForReduction(
dyn_cast<VPInstruction>(&R), State, OrigLoop,
State.CFG.VPBB2IRBB[ExitVPBB], ExpandedSCEVs);
State.CFG.VPBB2IRBB[ExitVPBB], VectorizingEpilogue);
}

// 2.6. Maintain Loop Hints
Expand Down Expand Up @@ -10233,7 +10233,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {

std::unique_ptr<VPlan> BestMainPlan(BestPlan.duplicate());
auto ExpandedSCEVs = LVP.executePlan(EPI.MainLoopVF, EPI.MainLoopUF,
*BestMainPlan, MainILV, DT, true);
*BestMainPlan, MainILV, DT, false);
++LoopsVectorized;

// Second pass vectorizes the epilogue and adjusts the control flow
Expand Down

0 comments on commit 4987772

Please sign in to comment.