| Issue |
234412
|
| Summary |
[InstCombine] Miscompilation where a nsz copysign is replaced by a magnitude that can be negative zero
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
sairam2661
|
**Fuzzer Generated Test**
**Test Commit**
[e633c7da8ff144a11b3d875956fbaea06b969070](https://github.com/llvm/llvm-project/commit/e633c7da8ff144a11b3d875956fbaea06b969070)
**Description**
`simplifyDemandedFPClassCopysignMag` replaces `copysign nsz (%x, %y)` with `%x`, but the result's sign still comes from `%y`: for `%x = -0.0` and positive `%y`, the source returns +0.0 and the target -0.0.
This appears to be a real issue based on discussion in #180906, #202453.
**Steps to reproduce**
- Minimized test case, `input.ll`
```llvm
define nofpclass(nan ninf nnorm nsub) half @f(half nofpclass(nan ninf nnorm nsub) %x, half %y) {
%r = call nsz half @llvm.copysign.f16(half %x, half %y)
ret half %r
}
declare half @llvm.copysign.f16(half, half)
```
**Output**
```llvm
define half @f(half nofpclass(31) %x, half %y) nofpclass(31) {
#0:
%r = copysign nsz half nofpclass(31) %x, %y
ret half %r
}
=>
define half @f(half nofpclass(31) %x, half %y) nofpclass(31) {
#0:
ret half nofpclass(31) %x
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
half nofpclass(31) %x = #x0000 (+0.0)
half %y = #x8001 (-0.000000059604?)
Source:
half %r = #x8000 (-0.0)
Target:
Source value: #x8000 (-0.0)
Target value: #x0000 (+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