<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/149977>149977</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DA] strongSIV produces incorrect results
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kasuga-fj
</td>
</tr>
</table>
<pre>
Input:
```llvm
define void @f(ptr %a, i64 %k) {
entry:
%mk = sub i64 0, %k
%kk = mul i64 %k, 2
%kk.inc = add i64 1, %kk
br label %loop
loop:
%i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
%subscript.0 = mul i64 %mk, %i
%subscript.1 = add i64 %subscript.0, %kk.inc
%idx.0 = getelementptr i8, ptr %a, i64 %subscript.0 ; a[-k * i]
%idx.1 = getelementptr i8, ptr %a, i64 %subscript.1 ; a[-k * i + (2 * k + 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, 3
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/5YrMG4vzd
There should be a dependency between the two stores to `idx.0` and `idx.1`. For example, when `k` is -1, the first store accesses `a[i]` and the second store accesses `a[i - 1]`. In this case, the first store writes to `a[0]` when `i` is 0, and the second store writes to the same location when `i` is 1, indicating a dependence.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VlGPozYQ_jWTlxEIDATywEOyuVT7UK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