| Issue |
234418
|
| Summary |
[InstCombine] Miscompilation where a select-shuffle fold keeps no-signed-zeros on the identity lanes it adds
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
sairam2661
|
**Fuzzer Generated Test**
**Reproducer**
https://alive2.llvm.org/ce/z/sXAu8w
**Test Commit**
[e633c7da8ff144a11b3d875956fbaea06b969070](https://github.com/llvm/llvm-project/commit/e633c7da8ff144a11b3d875956fbaea06b969070)
**Description**
`foldSelectShuffleWith1Binop` keeps `nsz` on the identity lane it adds to the `fmul`: for `%v = +0.0`, that lane may return -0.0 where the source returns `%v` (the fold drops `ninf` for this reason in #201315).
**Steps to reproduce**
- Minimized test case (src), `input.ll`
```llvm
define <2 x half> @f(<2 x half> nofpclass(nan) %v) {
%b = fmul nsz <2 x half> %v, <half 2.0, half 3.0>
%s = shufflevector <2 x half> %b, <2 x half> %v, <2 x i32> <i32 0, i32 3>
ret <2 x half> %s
}
```
- InstCombine output (tgt), `output.ll`
```llvm
define <2 x half> @f(<2 x half> nofpclass(nan) %v) {
%s = fmul nnan nsz <2 x half> %v, <half 2.000000e+00, half 1.000000e+00>
ret <2 x half> %s
}
```
**Output**
```
define <2 x half> @f(<2 x half> nofpclass(3) %v) {
#0:
%b = fmul nsz <2 x half> nofpclass(3) %v, { 0x4000, 0x4200 }
%s = shufflevector <2 x half> %b, <2 x half> nofpclass(3) %v, 0, 3
ret <2 x half> %s
}
=>
define <2 x half> @f(<2 x half> nofpclass(3) %v) {
#0:
%s = fmul nnan nsz <2 x half> nofpclass(3) %v, { 0x4000, 0x3c00 }
ret <2 x half> %s
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
<2 x half> nofpclass(3) %v = < poison, #x0000 (+0.0) >
Source:
<2 x half> %b = < poison, #x8000 (-0.0) >
<2 x half> %s = < poison, #x0000 (+0.0) >
Target:
<2 x half> %s = < poison, #x8000 (-0.0) >
Source value: < poison, #x0000 (+0.0) >
Target value: < poison, #x8000 (-0.0) >
Summary:
0 correct transformations
1 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
**CC**: @regehr
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs