[llvm] [VPlan] First step towards VPlan cost modeling (LegacyCM in CostCtx) (PR #92555)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 12:52:43 PDT 2024
================
@@ -920,6 +980,13 @@ void VPlan::execute(VPTransformState *State) {
"DT not preserved correctly");
}
+InstructionCost VPlan::cost(ElementCount VF, VPCostContext &Ctx) {
+ InstructionCost Cost = 0;
+ for (VPBlockBase *Block : vp_depth_first_shallow(getEntry()))
+ Cost += Block->cost(VF, Ctx);
+ return Cost;
----------------
ayalz wrote:
```suggestion
return getVectorLoopRegion()->cost(VF, Ctx);
```
?
CM computes cost of instructions inside the vector loop only, to be scaled by its VF. Should VPlan::cost() do the same, at least for this step which strives to match CM? A DFS scan from VPlan's Entry excludes the pre-preheader but includes the vector preheader and middle-block (the latter soon to be populated with recipes). Their recipes all presumably lack underlying Instructions so their CM cost should turn out zero, but better to be explicit and conservative.
https://github.com/llvm/llvm-project/pull/92555
More information about the llvm-commits
mailing list