| Issue |
234388
|
| Summary |
[InstCombine] Miscompilation where a sign test of a reciprocal ignores that the division can underflow to zero
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
sairam2661
|
**Fuzzer Generated Test**
**Test Commit**
[e633c7da8ff144a11b3d875956fbaea06b969070](https://github.com/llvm/llvm-project/commit/e633c7da8ff144a11b3d875956fbaea06b969070)
**Description**
`foldFCmpReciprocalAndZero` rewrites `(C / X) < 0.0` to `X < 0.0`, but `C / X` can underflow to ±0.0: for a small `C` and a large negative `X`, the source returns false and the target true.
**Steps to reproduce**
- Minimized test case, `input.ll`
```llvm
define i1 @f(float %x) {
%d = fdiv ninf float 1.0e-10, %x
%c = fcmp ninf olt float %d, 0.0
ret i1 %c
}
```
**Output**
```llvm
----------------------------------------
define i1 @f(float %x) {
#0:
%d = fdiv ninf float 1e-10, %x
%c = fcmp ninf olt float %d, 0e+00
ret i1 %c
}
=>
define i1 @f(float %x) {
#0:
%c = fcmp ninf olt float %x, 0e+00
ret i1 %c
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
float %x = #xfa5be6ff (-2.8544954e+35)
Source:
float %d = #x80000000 (-0.0)
i1 %c = #x0 (0)
Target:
i1 %c = #x1 (1)
Source value: #x0 (0)
Target value: #x1 (1)
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