[llvm] [VPlan] First step towards VPlan cost modeling. (PR #67934)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 13:02:41 PDT 2024
================
@@ -7395,6 +7396,177 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
return VF;
}
+static InstructionCost
+computeCostForRecipe(VPRecipeBase *R, ElementCount VF,
+ SmallPtrSetImpl<Instruction *> &SeenUI,
+ LoopVectorizationCostModel &CM,
+ const TargetTransformInfo &TTI, VPCostContext CostCtx) {
+ Instruction *UI = nullptr;
+ if (auto *S = dyn_cast<VPSingleDefRecipe>(R))
+ UI = dyn_cast_or_null<Instruction>(S->getUnderlyingValue());
+ if (UI && (CM.VecValuesToIgnore.contains(UI) || !SeenUI.insert(UI).second))
----------------
ayalz wrote:
If VecValuesToIgnore contains UI, was it ignored? Can this be an assert?
SeenUI: only one - the first - recipe holding the same underlying Instruction carries a cost? This ensures an underlying Inst cost is counted once, but if multiple recipes hold it (what/are there such cases?), all but the first are Valid cost free? This also takes care of IVInc instructions whose cost is counted elsewhere, and should not be counted here (although could discount their cost there, to keep it simple here?).
https://github.com/llvm/llvm-project/pull/67934
More information about the llvm-commits
mailing list