[NFC][InstSimplify] Add miscompiled testcase from D87188/D87197
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 18 Dec 2020 17:24:25 +0000 (20:24 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 18 Dec 2020 18:18:13 +0000 (21:18 +0300)
commit9b183a1452c7e5091be01661188b7cb04d842a4c
tree5eea1cc429615fcf65d7639ae7c0406ea28cc011
parent5f75dcf5719f8ba2819b73109888175cf92fe253
[NFC][InstSimplify] Add miscompiled testcase from D87188/D87197

Thanks to Dave Green for producing an actionable reproducer!
It is (obviously) a miscompile:
```
----------------------------------------
define i32 @select_abs_of_abs_eq_wrong(i32 %x, i32 %y) {
%0:
  %abs = abs i32 %x, 0
  %neg = sub i32 0, %abs
  %cmp = icmp eq i32 %y, 0
  %sel = select i1 %cmp, i32 %neg, i32 %abs
  ret i32 %sel
}
=>
define i32 @select_abs_of_abs_eq_wrong(i32 %x, i32 %y) {
%0:
  %abs = abs i32 %x, 0
  ret i32 %abs
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
i32 %x = #xe0000000 (3758096384, -536870912)
i32 %y = #x00000000 (0)

Source:
i32 %abs = #x20000000 (536870912)
i32 %neg = #xe0000000 (3758096384, -536870912)
i1 %cmp = #x1 (1)
i32 %sel = #xe0000000 (3758096384, -536870912)

Target:
i32 %abs = #x20000000 (536870912)
Source value: #xe0000000 (3758096384, -536870912)
Target value: #x20000000 (536870912)

Alive2: Transform doesn't verify!

```
llvm/test/Transforms/InstSimplify/abs_intrinsic.ll