Issue 149991
Summary [DA] Assume coefficient of subscript is non-zero
Labels llvm:analysis
Assignees
Reporter kasuga-fj
    Input:

```llvm
define void @f(ptr %a, i64 %k) {
entry:
  br label %loop

loop:
  %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
  %subscript = mul i64 %i, %k
  %idx = getelementptr i8, ptr %a, i64 %subscript
  store i8 42, ptr %idx
  %i.next = add i64 %i, 1
  %cond.exit = icmp eq i64 %i.next, 100
  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, align 1 --> Dst:  store i8 42, ptr %idx, align 1
  da analyze - none!
```

godbolt: https://godbolt.org/z/6eq4W84q5

This is incorrect when `%k` is zero, where the store accesses the same memory location in all iterations. At first glance, it seems that some routines in DA assume that the coefficient of the subscript is non-zero, which is not always the case.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to