[llvm] [AArch64][CostModel] Improve cost estimate of scalarizing a vector di… (PR #118055)

Sushant Gokhale via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 03:24:39 PST 2024


================
@@ -7,21 +7,21 @@ define i32 @sdiv() {
 ; CHECK-LABEL: 'sdiv'
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: %I128 = sdiv i128 undef, undef
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %I64 = sdiv i64 undef, undef
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 28 for instruction: %V2i64 = sdiv <2 x i64> undef, undef
----------------
sushgokh wrote:

changes in `llvm/test/Analysis/CostModel/AArch64/div.ll` are not completely orthogonal to my patch (or (1) is not completely orthogonal to (2) ).


[This](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp#L3479C1-L3486C10) piece of code needs change for following reasons:
1. Now that I have extra information about the scalars and information about the scalar type can be passed  i.e. instead of passing Op1Info and Op2Info, I need to pass information about the scalar. I forgot to update this. Will update the patch.
2. The extract cost, which contributes to the entire cost, is considered once instead of twice [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp#L3484) which is not correct I think. 

In short, updating this small piece of code would cause changes in `llvm/test/Analysis/CostModel/AArch64/div.ll`

The perf results, as mentioned in the description, are neutral.

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


More information about the llvm-commits mailing list