[llvm] [LV] Add VPlan planning context and result (PR #226415)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 03:06:43 PDT 2026


================
@@ -833,6 +833,52 @@ class VFSelectionContext {
   }
 };
 
+/// The plans and profitability results produced by a completed planning run.
+class VPlanPlanningResult {
+  friend class LoopVectorizationPlanner;
+
+  SmallVector<VPlanPtr, 4> VPlans;
+  SmallVector<VectorizationFactor, 8> ProfitableVFs;
+
+public:
+  VPlanPlanningResult() = default;
+  VPlanPlanningResult(VPlanPlanningResult &&) = default;
+  VPlanPlanningResult &operator=(VPlanPlanningResult &&) = default;
+  VPlanPlanningResult(const VPlanPlanningResult &) = delete;
+  VPlanPlanningResult &operator=(const VPlanPlanningResult &) = delete;
+
+  /// Return the VPlan for \p VF. At the moment, there is always a single VPlan
+  /// for each VF.
+  VPlan &getPlanFor(ElementCount VF) const;
+
+  /// Return true if there is a plan for \p VF.
+  bool hasPlanWithVF(ElementCount VF) const;
+};
+
+/// State shared by VPlan construction and cost-modeling for one planning run.
+///
+/// Keeping the cost model and the plans whose decisions it produced in the
+/// same context makes the dependency explicit when multiple cost models are
+/// used for the same loop. Finalizing the context destroys the cost model and
+/// returns the plans and profitability results needed by code generation.
+class VPlanPlanningContext {
----------------
david-arm wrote:

This might help, although we already have a similar `VFSelectionContext`. Not sure if it's possible to combine them?

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


More information about the llvm-commits mailing list