[llvm] [VPlan] Update getBestPlan to return VF, use also for epilogue vec. (PR #98821)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 06:03:48 PDT 2024
================
@@ -10015,21 +10012,25 @@ bool LoopVectorizePass::processLoop(Loop *L) {
} else {
// If we decided that it is *legal* to vectorize the loop, then do it.
+ ElementCount BestVF = LVP.getBestVF();
+ 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);
// Consider vectorizing the epilogue too if it's profitable.
VectorizationFactor EpilogueVF =
- LVP.selectEpilogueVectorizationFactor(VF.Width, IC);
+ LVP.selectEpilogueVectorizationFactor(BestVF, IC);
if (EpilogueVF.Width.isVector()) {
// The first pass vectorizes the main loop and creates a scalar epilogue
// to be vectorized by executing the plan (potentially with a different
// factor) again shortly afterwards.
- EpilogueLoopVectorizationInfo EPI(VF.Width, IC, EpilogueVF.Width, 1);
+ EpilogueLoopVectorizationInfo EPI(BestVF, IC, EpilogueVF.Width, 1);
EpilogueVectorizerMainLoop MainILV(L, PSE, LI, DT, TLI, TTI, AC, ORE,
EPI, &LVL, &CM, BFI, PSI, Checks);
assert(EPI.MainLoopVF == VF.Width && "VFs must match");
----------------
ayalz wrote:
```suggestion
assert(EPI.MainLoopVF == BestVF && "VFs must match");
```
or dropped - given that this holds by construction of EPI?
Maybe worth revisiting the use of `EPI` throughout, separately, as it leads to an inflation of VF's, a redundant setting of EpilogueUF asserted to be 1, a confusing resetting of `EPI.MainLoopVF = EPI.EpilogueVF;` below.
https://github.com/llvm/llvm-project/pull/98821
More information about the llvm-commits
mailing list