[llvm] LAA: generalize strides over unequal type sizes (PR #108088)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 09:08:10 PDT 2024


================
@@ -8,15 +8,21 @@ declare void @llvm.assume(i1)
 define void @different_non_constant_strides_known_backward(ptr %A) {
 ; CHECK-LABEL: 'different_non_constant_strides_known_backward'
 ; CHECK-NEXT:    loop:
-; CHECK-NEXT:      Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
-; CHECK-NEXT:  Unknown data dependence.
+; CHECK-NEXT:      Memory dependences are safe with run-time checks
----------------
artagnon wrote:

I think you're right: I didn't check the actual runtime checks generated. LAA prints the runtime checks correctly:

```
; CHECK-NEXT:      Run-time memory checks:
; CHECK-NEXT:      Check 0:
; CHECK-NEXT:        Comparing group ([[GRP1:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep.mul.2 = getelementptr inbounds i32, ptr %A, i64 %iv.mul.2
; CHECK-NEXT:        Against group ([[GRP2:0x[0-9a-f]+]]):
; CHECK-NEXT:          %gep = getelementptr inbounds i32, ptr %A, i64 %iv
```

For some reason, the RT-check generation routine forgets to add the `inbounds` to the GEPs, and I wonder if this is an underlying bug in LAA.

Another issue is that, we seem to be overly aggressive about generating runtime checks that we're not able to prove are always false (perhaps with `inbounds`, it can be proven?).

Will investigate in more detail, and take a fresh look at the patch, thanks!

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


More information about the llvm-commits mailing list