[llvm] [CostModel] Remove optional from InstructionCost::getValue() (PR #135596)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 22 12:03:00 PDT 2025
================
@@ -205,8 +205,7 @@ static CostType calculateFunctionCosts(GetTTIFn GetTTI, Module &M,
TTI.getInstructionCost(&I, TargetTransformInfo::TCK_CodeSize);
assert(Cost != InstructionCost::getMax());
// Assume expensive if we can't tell the cost of an instruction.
- CostType CostVal =
- Cost.getValue().value_or(TargetTransformInfo::TCC_Expensive);
+ CostType CostVal = Cost.getValueOr(TargetTransformInfo::TCC_Expensive);
----------------
davemgreen wrote:
That sounds sensible to me, I might personally remove all the TCC_ costs as "0" or "1" are fairly self-explanatory numbers. TCC_Expensive would need to be replaced by something. I recently went and measured the cost of a divide, using dynamorio to collect the distributions of numerators/denominators and checking the latency of divides with those values. The real value would vary depending on how you weighted it (there were a lot of 1/1 divides). Having it as 4 at least makes a starting-point, and targets can override it when they come up with a better value.
https://github.com/llvm/llvm-project/pull/135596
More information about the llvm-commits
mailing list