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

    <tr>
        <th>Summary</th>
        <td>
            InstCombine: incorrect copysign formation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            miscompilation,
            llvm:instcombine
      </td>
    </tr>

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

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

<pre>
    Alive2 reports a bug in the following transformation from `Transforms/InstCombine/select.ll`:
```llvm
define float @copysign1(float %x) {
  %i = bitcast float %x to i32
  %ispos = icmp sgt i32 %i, 4294967295
  %r = select i1 %ispos, float 1.000000, float -1.000000
  ret float %r
}
=>
define float @copysign1(float %x) {
  %r = copysign float 1.000000, %x, exceptions=ignore
  ret float %r
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
float %x = #xff800008 (NaN)

Source:
i32 %i = #xff800008 (4286578696, -8388600)
i1 %ispos = #x0 (0)
float %r = #xbf800000 (-1)

Target:
float %r = #x3f800000 (1)
Source value: #xbf800000 (-1)
Target value: #x3f800000 (1)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVE2PmzAQ_TXmYiUCOwH7wCG72ZV62UrbVe8GBuLKYGSbNPvva5sksO2qqtQIBTx-b-bNh13p5r08KHkGgg2M2jiLBa6mDssBuxPgViulf8qhw86Iwbba9MJJPeDW6B6jPH27mS0iz18G6x51X8kB_MqCgtptlfIwRA8oPaL0EL7jo9S5n00NtJ6AW6WFw2iX1np8t7IbMkTY1Uj2F0Q4RsXDTMHBJDGiR1xJVwvr8ILETmNJyRppR20jWtb9iG3nAiDuIPKId4TveF4Qvl9xTMTPOWCZ3d0Ewhwr26bxt1g2d9PVj4GVMHOtQHG8ftAjok__V4NZ5Q39ibCZ9ojhUsMYOmc9wUO1gX8S-fax7Y0GOyBSOHwGI9t3RLIrIf4_vb5-ffW9xt-FmgD30npeffoAuYh-VHAfiFXfQiqI0EvbsiCf-QV7ES8-67WDb3oy9cK_NfJT9o6wfF-wnOehBhtGGctDXa4OV22909PAWyBLYe6Iag4QgZvsN3VvwnTg_sxuodMVfWHPWeFzqFso4F8CzSE-Qj93ej9sCZRZnnPG9owXSVPShlMuEiedgnJ9ar07OdTamDD1y1jd-p9MRpUn50YbMiTP_umkO03Vtta9X8RDPb82o9E_vBe_lNZOEO6HPfelTU5llrGc5E0FnOY0FXzXsJoQBgwKnjcAiRIVKFui_QMixE-R9z5KFSV4wzzXJAajB-nl17dLh6D9MZElSQnJSJqlPMso2XJK80JACzRlWcWpP2DQC6m2wcVWmy4xZdTsbz7rN5W0zi6bwoYqAEQ93r-Y3EmbcpgGPSo9gk1ihmVM7xcpcYX1">