[llvm] [VPlan] Return Max from computeCost without underlying instrs. (PR #109708)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 07:01:45 PDT 2024


================
@@ -298,9 +293,13 @@ InstructionCost VPRecipeBase::cost(ElementCount VF, VPCostContext &Ctx) {
     return 0;
 
   InstructionCost RecipeCost = computeCost(VF, Ctx);
-  if (UI && ForceTargetInstructionCost.getNumOccurrences() > 0 &&
-      RecipeCost.isValid())
+  if (ForceTargetInstructionCost.getNumOccurrences() > 0 &&
+      (RecipeCost.isValid() && RecipeCost != InstructionCost::getMax()))
     RecipeCost = InstructionCost(ForceTargetInstructionCost);
+  // Max cost is used as a sentinel value to detect recipes without underlying
+  // instructions for which no forced target instruction cost should be applied.
+  else if (RecipeCost == InstructionCost::getMax())
----------------
ayalz wrote:

Should the logic be as follows:

If UI is to be skipped, zero cost should be (dumped? and) returned.

If VPlan-based cost cannot be computed (yet, i.e., computeCost() returned null), fallback on legacy cost model using UI - asserting UI is available?

If computed cost (VPlan or legacy based) is invalid, it should be (dumped and) returned.

If ForceTargetInstructionCost, the cost should be either ForceTargetInstructionCost or zero, depending on whether UI exists or not.

Sounds right?

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


More information about the llvm-commits mailing list