[llvm] [SLP] Fix cost estimation of external uses with wrong VF (PR #148185)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 04:00:23 PDT 2025


================
@@ -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
----------------
gbossu 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.

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)?

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


More information about the llvm-commits mailing list