[llvm] [LV] isScalarWithPredication to check for interleaved accesses (PR #194579)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 02:19:29 PDT 2026


================
@@ -161,8 +161,10 @@ define void @test(ptr noalias nocapture %points, ptr noalias nocapture readonly
 ; ENABLED_MASKED_STRIDED:  LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx6, align 2
 ; ENABLED_MASKED_STRIDED:  Cost of 2 for VF 2: profitable to scalarize store i16 %0, ptr %arrayidx6, align 2
 ; ENABLED_MASKED_STRIDED:  Cost of 4 for VF 4: profitable to scalarize store i16 %0, ptr %arrayidx6, align 2
-; ENABLED_MASKED_STRIDED:  Cost of 8 for VF 8: profitable to scalarize store i16 %0, ptr %arrayidx6, align 2
-; ENABLED_MASKED_STRIDED:  Cost of 16 for VF 16: profitable to scalarize store i16 %0, ptr %arrayidx6, align 2
+; ENABLED_MASKED_STRIDED:  Cost of 12 for VF 8: INTERLEAVE-GROUP with factor 3 at <badref>, ir<%arrayidx6>, ir<%cmp1>
+; ENABLED_MASKED_STRIDED:    store ir<%0> to index 0
+; ENABLED_MASKED_STRIDED:  Cost of 22 for VF 16: INTERLEAVE-GROUP with factor 3 at <badref>, ir<%arrayidx6>, ir<%cmp1>
+; ENABLED_MASKED_STRIDED:    store ir<%0> to index 0
----------------
gbossu wrote:

Yes there is something missing, the costs from `precomputeCosts` are not shown.

According to the cost model, interleaved accesses give a lower total cost, so it does make sense that they are chosen over scalarization. It's just hard to see in the test, because part of that scalarization cost (branches) used to be added by `precomputeCosts`. Now it's not anymore because we properly take the widen decision into account (i.e. we keep the widening decision and the cost in sync).

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


More information about the llvm-commits mailing list