Issue 89516
Summary miscompile of vanilla integer code by InstCombine
Labels miscompilation, llvm:instcombine
Assignees
Reporter regehr
    https://alive2.llvm.org/ce/z/jRfVLr

this function:
```llvm
define i8 @f(i8 %0, i8 %1) {
  %3 = icmp slt i8 %1, 0
  %4 = shl i8 1, %0
  %5 = srem i8 1, %4
  %6 = add i8 %5, %4
  %7 = select i1 %3, i8 %6, i8 %5
  ret i8 %7
}
```
is getting mis-optimized to:
```llvm
define i8 @f(i8 %0, i8 %1) {
  %3 = icmp ne i8 %0, 0
  %4 = zext i1 %3 to i8
  ret i8 %4
}
```
here I'll just give Alive's work:
```
Example:
i8 %#0 = #x00 (0)
i8 %#1 = #xff (255, -1)

Source:
i1 %#3 = #x1 (1)
i8 %#4 = #x01 (1)
i8 %#5 = #x00 (0)
i8 %#6 = #x01 (1)
i8 %#7 = #x01 (1)

Target:
i1 %#3 = #x0 (0)
i8 %#4 = #x00 (0)
Source value: #x01 (1)
Target value: #x00 (0)
```

cc @nunoplopes @hatsunespica
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to