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

    <tr>
        <th>Summary</th>
        <td>
            Wrong folding of `select` into ops
        </td>
    </tr>

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

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

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

<pre>
    The compiler explorer's alive2 times out for this case.
But I post a proof that the optimization actually happens: https://alive2.llvm.org/ce/z/oJb3ii


This is the Alive2 report on my machine:
```llvm
----------------------------------------
define float @fmul_by_self_if_0_oeq_zero_f32_fmul_nnan_ninf_nsz.2(float %x) {
#0:
  %#1 = fcmp ule float %x, 0.000000
  %scaled.x = fmul nnan ninf nsz float %x, %x
  %scaled.if.denormal = select nnan i1 %#1, float %x, float %scaled.x
  ret float %scaled.if.denormal
}
=>
define float @fmul_by_self_if_0_oeq_zero_f32_fmul_nnan_ninf_nsz.2(float %x) {
#0:
  %#1 = fcmp ule float %x, 0.000000
  %scaled.x = select nnan i1 %#1, float 1.000000, float %x
  %scaled.if.denormal = fmul nnan ninf nsz float %scaled.x, %x
  ret float %scaled.if.denormal
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
float %x = #xff800000 (-oo)

Source:
i1 %#1 = #x1 (1)
float %scaled.x = poison
float %scaled.if.denormal = #xff800000 (-oo)

Target:
i1 %#1 = #x1 (1)
float %scaled.x = #x3f800000 (1)
float %scaled.if.denormal = poison
Source value: #xff800000 (-oo)
Target value: poison

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVV9vqzYU_zTOy1EjsCk0Dzy0y420vUzqKu0RGTgOrowPs02W5NNPhiRN0t3bTXsaqgrB5_fHP3Ns6b3eWsSSPb6wx_VC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