Skip to content

Commit

Permalink
[VPlan] Rename getBestPlanFor -> getPlanFor (NFC).
Browse files Browse the repository at this point in the history
As suggested in llvm#103033, more
accurately rename to getPlanFor , as it simplify returns the VPlan for
VF, relying on the fact that there is a single VPlan for each VF at the
moment.
  • Loading branch information
fhahn committed Aug 19, 2024
1 parent abf69a1 commit f2fcd9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,9 @@ class LoopVectorizationPlanner {
/// VF and its cost.
VectorizationFactor planInVPlanNativePath(ElementCount UserVF);

/// Return the best VPlan for \p VF.
VPlan &getBestPlanFor(ElementCount VF) const;
/// Return the VPlan for \p VF. At the moment, there is always a single VPlan
/// for each VF.
VPlan &getPlanFor(ElementCount VF) const;

/// Compute and return the most profitable vectorization factor. Also collect
/// all profitable VFs in ProfitableVFs.
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9487,7 +9487,7 @@ static bool processLoopInVPlanNativePath(
if (VPlanBuildStressTest || VectorizationFactor::Disabled() == VF)
return false;

VPlan &BestPlan = LVP.getBestPlanFor(VF.Width);
VPlan &BestPlan = LVP.getPlanFor(VF.Width);

{
bool AddBranchWeights =
Expand Down Expand Up @@ -9967,7 +9967,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
ElementCount BestVF = LVP.computeBestVF();
assert(BestVF.isScalar() &&
"VPlan cost model and legacy cost model disagreed");
VPlan &BestPlan = LVP.getBestPlanFor(BestVF);
VPlan &BestPlan = LVP.getPlanFor(BestVF);
LVP.executePlan(BestVF, IC, BestPlan, Unroller, DT, false);

ORE->emit([&]() {
Expand All @@ -9983,7 +9983,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
LLVM_DEBUG(dbgs() << "VF picked by VPlan cost model: " << BestVF << "\n");
assert(VF.Width == BestVF &&
"VPlan cost model and legacy cost model disagreed");
VPlan &BestPlan = LVP.getBestPlanFor(BestVF);
VPlan &BestPlan = LVP.getPlanFor(BestVF);
// Consider vectorizing the epilogue too if it's profitable.
VectorizationFactor EpilogueVF =
LVP.selectEpilogueVectorizationFactor(BestVF, IC);
Expand All @@ -10009,7 +10009,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
ORE, EPI, &LVL, &CM, BFI, PSI,
Checks);

VPlan &BestEpiPlan = LVP.getBestPlanFor(EPI.EpilogueVF);
VPlan &BestEpiPlan = LVP.getPlanFor(EPI.EpilogueVF);
VPRegionBlock *VectorLoop = BestEpiPlan.getVectorLoopRegion();
VPBasicBlock *Header = VectorLoop->getEntryBasicBlock();
Header->setName("vec.epilog.vector.body");
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Vectorize/VPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,11 +1680,11 @@ void LoopVectorizationPlanner::buildVPlans(ElementCount MinVF,
}
}

VPlan &LoopVectorizationPlanner::getBestPlanFor(ElementCount VF) const {
VPlan &LoopVectorizationPlanner::getPlanFor(ElementCount VF) const {
assert(count_if(VPlans,
[VF](const VPlanPtr &Plan) { return Plan->hasVF(VF); }) ==
1 &&
"Best VF has not a single VPlan.");
"Multiple VPlans for VF.");

for (const VPlanPtr &Plan : VPlans) {
if (Plan->hasVF(VF))
Expand Down

0 comments on commit f2fcd9c

Please sign in to comment.