Issue |
149501
|
Summary |
[DA] Does not account for wrapping accesses
|
Labels |
new issue
|
Assignees |
|
Reporter |
kasuga-fj
|
Input:
```llvm
define void @f(ptr %a, i64 %n, i64 %m) {
entry:
%bound = sub i64 %m, %n
br label %loop
loop:
%i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
%subscript.0 = add i64 %i, %n
%subscript.1 = add i64 %i, %m
%idx.0 = getelementptr i8, ptr %a, i64 %subscript.0
%idx.1 = getelementptr i8, ptr %a, i64 %subscript.1
store i8 42, ptr %idx.0
store i8 42, ptr %idx.1
%i.next = add i64 %i, 1
%cond.exit = icmp eq i64 %i.next, %bound
br i1 %cond.exit, label %exit, label %loop
exit:
ret void
}
```
Result:
```
$ opt -passes='print<da>' -disable-output test.ll
Printing analysis 'Dependence Analysis' for function 'f':
Src: store i8 42, ptr %idx.0, align 1 --> Dst: store i8 42, ptr %idx.0, align 1
da analyze - none!
Src: store i8 42, ptr %idx.0, align 1 --> Dst: store i8 42, ptr %idx.1, align 1
da analyze - none!
Src: store i8 42, ptr %idx.1, align 1 --> Dst: store i8 42, ptr %idx.1, align 1
da analyze - none!
```
godbolt: https://godbolt.org/z/jvascaoo7
At the very least, when both `%n` and `%m` are zero, there is a dependency between the two stores within a single iteration.
Here is a portion of the debug output related to the analysis between them:
```
testing subscript 0, SIV
src = "" + %a),+,1}<%loop>
dst = {(%m + %a),+,1}<%loop>
Strong SIV test
Coeff = 1, i64
SrcConst = (%n + %a), ptr
DstConst = (%m + %a), ptr
Delta = ((-1 * %m) + %n), i64
UpperBound = (-1 + (-1 * %n) + %m), i64
none!
```
The root cause seems to be that DA uses the backedge-taken count as the iteration count without considering any wrapping accesses (ref: [strongSIVtest](https://github.com/llvm/llvm-project/blob/6c63316ee17462c97c722a960680b2b45d2fff4d/llvm/lib/Analysis/DependenceAnalysis.cpp#L1268-L1283)). In this case, the issue is caused by `strongSIVtest`, but I suspect similar issues may exist elsewhere in DA.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs