[llvm] [DA] do not handle GEPs with different types (PR #144088)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 13 09:36:52 PDT 2025
================
@@ -149,8 +145,7 @@ define void @multidim_accesses(ptr %A) {
; CHECK-NEXT: Src: store i32 1, ptr %idx0, align 4 --> Dst: store i32 1, ptr %idx0, align 4
; CHECK-NEXT: da analyze - none!
; CHECK-NEXT: Src: store i32 1, ptr %idx0, align 4 --> Dst: store i32 1, ptr %idx1, align 4
-; FIXME: the dependence distance is not constant. Distance vector should be [* * *|<]!
-; CHECK-NEXT: da analyze - consistent output [0 0 0|<]!
+; CHECK-NEXT: da analyze - confused!
----------------
kasuga-fj wrote:
This is just an example of DA missing some dependencies that should exist, due to the delinearization reasoning based on the GEP source element type. There are variants of this example that is not resolved by your patch, e.g., like the following:
```
define void @multidim_accesses(ptr %A) {
entry:
br label %for.i
for.i:
%i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ]
br label %for.j
for.j:
%j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j.inc ]
br label %for.k
for.k:
%k = phi i64 [ 0, %for.j ], [ %k.inc, %for.k.inc ]
%k.inc = add nsw i64 %k, 1
%idx0 = getelementptr inbounds [256 x [256 x [256 x i32]]], ptr %A, i64 %i, i64 %j, i64 %k
store i64 1, ptr %idx0
%idx1 = getelementptr inbounds [256 x [256 x [256 x i32]]], ptr %A, i64 %i, i64 %j, i64 %k.inc
store i64 1, ptr %idx1
br label %for.k.inc
for.k.inc:
%k.exitcond = icmp eq i64 %k.inc, 255
br i1 %k.exitcond, label %for.j.inc, label %for.k
for.j.inc:
%j.inc = add nsw i64 %j, 1
%j.exitcond = icmp eq i64 %j.inc, 256
br i1 %j.exitcond, label %for.i.inc, label %for.j
for.i.inc:
%i.inc = add nsw i64 %i, 1
%i.exitcond = icmp eq i64 %i.inc, 256
br i1 %i.exitcond, label %end, label %for.i
end:
ret void
}
```
A portion of the output is as follows:
```
Src: store i64 1, ptr %idx0, align 4 --> Dst: store i64 1, ptr %idx1, align 4
da analyze - output [= = >]!
```
However, the latter half of the first store overlaps with the first half of the second store (within the same iteration). Therefore, an `=` dependency exists for the k-loop, but DA currently does not recognize it.
https://github.com/llvm/llvm-project/pull/144088
More information about the llvm-commits
mailing list