<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/234388>234388</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Miscompilation where a sign test of a reciprocal ignores that the division can underflow to zero
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          sairam2661
      </td>
    </tr>
</table>

<pre>
    **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
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVUFv2zgT_TX0ZRCDIiVZOujg2PWH71AUSItFsTdKHNpcUKRAUk6aX78g5ThuFs1mKwiwpZk3b-ZRMyNC0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