[llvm] [VPlan] Return Max from computeCost without underlying instrs. (PR #109708)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 11:58:45 PDT 2024
================
@@ -312,15 +311,19 @@ InstructionCost VPRecipeBase::cost(ElementCount VF, VPCostContext &Ctx) {
InstructionCost VPRecipeBase::computeCost(ElementCount VF,
VPCostContext &Ctx) const {
// Compute the cost for the recipe falling back to the legacy cost model using
- // the underlying instruction. If there is no underlying instruction, returns
- // 0.
+ // the underlying instruction. If there is no underlying instruction or the
+ // cost is computed by the recipe's computeCost, returns
+ // InstructionCost::getMax. It is used as a sentinel value to detect recipes
+ // without underlying instructions for which no forced target instruction cost
+ // should be applied.
+
Instruction *UI = getInstructionForCost(this);
if (UI && isa<VPReplicateRecipe>(this)) {
// VPReplicateRecipe may be cloned as part of an existing VPlan-to-VPlan
// transform, avoid computing their cost multiple times for now.
Ctx.SkipCostComputation.insert(UI);
}
- return UI ? Ctx.getLegacyCost(UI, VF) : 0;
+ return UI ? Ctx.getLegacyCost(UI, VF) : InstructionCost::getMax();
----------------
fhahn wrote:
Adjusted to use getLegacyCost in a few relevant sub-classes (VPSingleDefRecipe/VPInterleaveRecipe). Should hopefully be clearer and simpler now
https://github.com/llvm/llvm-project/pull/109708
More information about the llvm-commits
mailing list