[llvm] [VPlan] Only use selectVectorizationFactor for cross-check (NFCI). (PR #103033)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 09:02:25 PDT 2024


================
@@ -9883,20 +9879,18 @@ bool LoopVectorizePass::processLoop(Loop *L) {
   unsigned UserIC = Hints.getInterleave();
 
   // Plan how to best vectorize, return the best VF and its cost.
-  std::optional<VectorizationFactor> MaybeVF = LVP.plan(UserVF, UserIC);
+  LVP.plan(UserVF, UserIC);
+  VectorizationFactor VF = LVP.getBestVF();
+  unsigned IC = 1;
 
   if (ORE->allowExtraAnalysis(LV_NAME))
     LVP.emitInvalidCostRemarks(ORE);
 
-  VectorizationFactor VF = VectorizationFactor::Disabled();
-  unsigned IC = 1;
-
   bool AddBranchWeights =
       hasBranchWeightMD(*L->getLoopLatch()->getTerminator());
   GeneratedRTChecks Checks(*PSE.getSE(), DT, LI, TTI,
                            F->getDataLayout(), AddBranchWeights);
-  if (MaybeVF) {
-    VF = *MaybeVF;
+  if (LVP.hasPlanWithVF(VF.Width)) {
----------------
ayalz wrote:

ok, right, VectorizationFactor::Disabled (Width == 1) is distinct from "invalid" (can be Width == 0).
Agreed, computeBestVF() should return the latter instead of the former, when there are no plans.
It is somewhat confusing to ask if LVP has a plan with its best VF or not - one would expect that to be asserted - provided this best VF is valid.
Sure, can be done independently.

https://github.com/llvm/llvm-project/pull/103033


More information about the llvm-commits mailing list