[llvm] [SLP] Fix cost estimation of external uses with wrong VF (PR #148185)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 11 05:10:13 PDT 2025
=?utf-8?q?Gaƫtan?= Bossu <gaetan.bossu at arm.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/148185 at github.com>
================
@@ -31,3 +31,34 @@ define void @test() {
store double %res4, ptr getelementptr inbounds ([8 x double], ptr @dst, i32 0, i64 3), align 8
ret void
}
+
+; Same as above, but %a7 is also used as a scalar and must be extracted from
+; the wide load. (Or in this case, kept as a scalar load).
+define double @test_with_extract() {
+; CHECK-LABEL: @test_with_extract(
+; CHECK-NEXT: [[TMP1:%.*]] = load <8 x double>, ptr @src, align 8
+; CHECK-NEXT: [[A7:%.*]] = load double, ptr getelementptr inbounds ([8 x double], ptr @src, i32 0, i64 7), align 8
----------------
alexey-bataev wrote:
> The cost is actually the same, because the Lane idx is essentially ignored by TTI implementations of `getVectorInstrCost()`. However, querying the cost for a lane that is out-of-bounds is still wrong.
>
I don't think it is true. In many cases, an extract from Index 0 is cheaper than an extract from other lanes, so getVectorInstrCost checks for the lane index.
I think you can see the difference if the original vector factor occupies more than a single register. In this case, some type legalization (spanning across registers) may add to the cost.
> In my local experiments with REVEC, I ended up querying the extraction cost of a sub-vector with an index that is out of bounds, and that did trigger an assert in `getShuffleCost()`. I just cannot find a test that reproduces the issue without bringing in more changes.
>
> Do you still want me to separate the test in a different file and show the costs (even though they would not change)?
Would be good to try to adjust the test to either cause a crash, or show cost changes
https://github.com/llvm/llvm-project/pull/148185
More information about the llvm-commits
mailing list