| Issue |
234697
|
| Summary |
[InstCombine] Miscompilation while negating a float subtraction by swapping its operands
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
sairam2661
|
**Fuzzer Generated Test**
**Reproducer**
https://alive2.llvm.org/ce/z/6haXBe
**Test Commit**
[e633c7da8ff144a11b3d875956fbaea06b969070](https://github.com/llvm/llvm-project/commit/e633c7da8ff144a11b3d875956fbaea06b969070)
**Description**
Since `fneg nsz (fsub x, y)` equals `fsub y, x` up to the sign of zero, InstCombine (`visitFNeg`) builds the new `fsub` with `CreateFSubFMF(Y, X, &I)`, which copies the `fneg`'s `ninf` onto it.
So, for `x = y = +inf` the target is poison where the source's `fsub` produced a NaN and the `fneg` returned it (this appears to be similar to #228557, whose fix #228671 changes only `hoistFNegAboveFMulFDiv`)
**Steps to reproduce**
- Minimized test case (src), `input.ll`
```llvm
define half @f(half %x, half %y) {
%s = fsub half %x, %y
%r = fneg ninf nsz half %s
ret half %r
}
```
- InstCombine output (tgt), `output.ll`
```llvm
define half @f(half %x, half %y) {
%r = fsub ninf nsz half %y, %x
ret half %r
}
```
**Output**
```txt
define half @f(half %x, half %y) {
#0:
%s = fsub half %x, %y
%r = fneg ninf nsz half %s
ret half %r
}
=>
define half @f(half %x, half %y) {
#0:
%r = fsub ninf nsz half %y, %x
ret half %r
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
half %x = #xfc01 (SNaN)
half %y = #xfc00 (-oo)
Source:
half %s = #xfe00 (QNaN)
half %r = #x7e00 (QNaN)
Target:
half %r = poison
Source value: #x7e00 (QNaN)
Target value: poison
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