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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 05:12:15 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)) {
----------------
fhahn wrote:

At the moment, VF.Width may be 1 (disabled), but it is still considered valid, if a plan with VF = 1 exists, for interleaving only.

We could update `getBestVF` to return Width == 0 if no plans exist or check if no plans exist here instead.

Either would probably be done independently?

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


More information about the llvm-commits mailing list