Issue 175729
Summary indvars miscompile
Labels
Assignees
Reporter mikaelholmen
    llvm commit: 4ef3f8dbc1c
Reproduce with:
```opt -passes=indvars bbi-113977.ll -S -o -```
Result:
```
define i16 @main() {
entry:
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %entry
  br i1 false, label %if.then, label %vector.body

if.then:                                          ; preds = %vector.body
  ret i16 0
}
```
Notice the infinite ```vector.body``` loop.

If we remove the "nuw" from the add
```%vec.next = add nuw i32 %vec, 4```
we instead get the correct result
```
define i16 @main() {
entry:
  br label %vector.body

vector.body: ; preds = %vector.body, %entry
  br i1 true, label %if.then, label %vector.body

if.then:                                          ; preds = %vector.body
  ret i16 0
}
```
But the result of the add is only used in a phi, which in turn is only used in the add, so it shouldn't matter.

This seems to be very old.

https://godbolt.org/z/Tbqc6Mv8a

[bbi-113977.ll.gz](https://github.com/user-attachments/files/24585344/bbi-113977.ll.gz)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to