[llvm] [VPlan] Unify inner and outer loop paths (NFCI). (PR #192868)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 19 13:20:19 PDT 2026


================
@@ -3446,8 +3446,61 @@ FixedScalableVFPair LoopVectorizationCostModel::computeFeasibleMaxVF(
   return Result;
 }
 
+// This function will select a scalable VF if the target supports scalable
+// vectors and a fixed one otherwise.
+// TODO: we could return a pair of values that specify the max VF and
+// min VF, to be used in `buildVPlans(MinVF, MaxVF)` instead of
+// `buildVPlans(VF, VF)`. We cannot do it because VPLAN at the moment
+// doesn't have a cost model that can choose which plan to execute if
+// more than one is generated.
+static ElementCount determineVPlanVF(const TargetTransformInfo &TTI,
+                                     LoopVectorizationCostModel &CM) {
+  auto [_, WidestType] = CM.getSmallestAndWidestTypes();
+
+  auto RegKind = TTI.enableScalableVectorization()
+                     ? TargetTransformInfo::RGK_ScalableVector
+                     : TargetTransformInfo::RGK_FixedWidthVector;
+
+  TypeSize RegSize = TTI.getRegisterBitWidth(RegKind);
+  unsigned N = RegSize.getKnownMinValue() / WidestType;
+  return ElementCount::get(N, RegSize.isScalable());
+}
----------------
artagnon wrote:

Confused how this is here? I already see a determineVPlanVF in LV.cpp?

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


More information about the llvm-commits mailing list