[llvm] [VPlan] Construct VPlan0 once, share across buildVPlans calls. (NFC) (PR #197276)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 20 06:54:43 PDT 2026


================
@@ -896,7 +896,10 @@ class LoopVectorizationPlanner {
   /// Build VPlans for power-of-2 VF's between \p MinVF and \p MaxVF inclusive,
   /// according to the information gathered by Legal when it checked if it is
   /// legal to vectorize the loop.
-  void buildVPlans(ElementCount MinVF, ElementCount MaxVF);
+  void buildVPlans(VPlan &VPlan0, ElementCount MinVF, ElementCount MaxVF);
+
+  /// Build base VPlan0 with scalar transformations applied.
+  VPlanPtr buildVPlan0();
----------------
ayalz wrote:

Better place first, prefix with tryTo, and call this VPlan1?
```suggestion
  /// Build an initial VPlan, with HCFG wrapping the original scalar loop and scalar transformations applied. Returns null if an initial VPlan cannot be built.
  VPlanPtr tryToBuildVPlan1();
  
  /// Build a VPlan using VPRecipes according to the information gathered by
  /// Legal and VPlan-based analysis. For outer loops, performs basic recipe
  /// conversion only. For inner loops, \p Range's largest included VF is
  /// restricted to the maximum VF the returned VPlan is valid for. If no VPlan
  /// can be built for the input range, set the largest included VF to the
  /// maximum VF for which no plan could be built. Each VPlan is built starting
  /// from a copy of \p InitialPlan, which is a plain CFG VPlan wrapping the
  /// original scalar loop.
  VPlanPtr tryToBuildVPlan(VPlanPtr InitialPlan, VFRange &Range);

  /// Build VPlans for power-of-2 VF's between \p MinVF and \p MaxVF inclusive,
  /// according to the information gathered by Legal when it checked if it is
  /// legal to vectorize the loop.
  void buildVPlans(VPlan &VPlan0, ElementCount MinVF, ElementCount MaxVF);
```

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


More information about the llvm-commits mailing list