[llvm] [LV] Thread an explicit CM param through VPlan-building/costing helpers (PR #224836)
Kiran Chandramohan via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 02:53:03 PDT 2026
================
@@ -896,15 +896,18 @@ class LoopVectorizationPlanner {
/// A builder used to construct the current plan.
VPBuilder Builder;
- /// Computes the cost of \p Plan for vectorization factor \p VF.
+ /// Computes the cost of \p Plan for vectorization factor \p VF, using
+ /// \p EnabledCM as the cost model (the main loop's cost model, or a
+ /// separate one when costing a tail-folded epilogue).
///
/// The current implementation requires access to the
/// LoopVectorizationLegality to handle inductions and reductions, which is
/// why it is kept separate from the VPlan-only cost infrastructure.
///
/// TODO: Move to VPlan::cost once the use of LoopVectorizationLegality has
/// been retired.
- InstructionCost cost(VPlan &Plan, ElementCount VF, VPRegisterUsage *RU) const;
+ InstructionCost cost(VPlan &Plan, ElementCount VF, VPRegisterUsage *RU,
----------------
kiranchandramohan wrote:
Would grouping the cost-model and plans via a VPlanPlanningContext as in https://github.com/llvm/llvm-project/pull/226415 help?
```
VPlanPlanningContext MainCtx(createMainCostModel());
LVP.plan(MainCtx, UserVF, UserIC);
auto [MainVF, MainPlan] = LVP.computeBestVF(MainCtx);
VPlanPlanningContext EpilogueCtx(
createEpilogueCostModel(..));
LVP.plan(EpilogueCtx, EpilogueVF, EpilogueIC);
LVP.computeBestVF(EpilogueCtx);
```
https://github.com/llvm/llvm-project/pull/224836
More information about the llvm-commits
mailing list