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

    <tr>
        <th>Summary</th>
        <td>
            fcmp and select of FP constant is not canonicalized to RHS
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:optimizations
      </td>
    </tr>

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

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

<pre>
    A select of FP constants based on an fcmp isn't canonicalized to have the select constant be on the RHS. The equivalent canonicalization is performed for integers

```
define double @src(double %arg, double %arg1) {
bb:
  %i = fcmp oge double %arg, 0x4086395A2079B70C
  %i2 = select i1 %i, double 0x7FF0000000000000, double %arg1
  ret double %i2
}

define double @tgt(double %arg, double %arg1) {
bb:
 %i = fcmp ult double %arg, 0x4086395A2079B70C
  %i2 = select i1 %i, double %arg1, double 0x7FF0000000000000
  ret double %i2
}

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU9tunDAQ_RrzMsrKDLflgYdNViiPVdIfMPYAroy9tU2U9usrWDbdVVaVqhYhkOdymHOYI0LQgyVqWPHIimMi5jg63wgfyE5J59SP5gCBDMkIrof2C0hnQxQ2BuhEIAXOgrDQy-kEOliGVQQprLNaCqN_koLoYBRvBHGkC9IFAzpa-pfMy_PrDr6OBPR91m_CkL3BEVE7CzrAiXzv_EQKeudB20gD-cD4kfHD9iz5dq9HRb22BMrNnSFgOQ9eMtxfzlgIPzB8gptAyrAGVj2eIbqOZRs4LAUaWHY8U3YDwSco_p7zfZnVxQF5VT9W_Om6GdfuTQmdrrGrAfh71bb8-roz3QbnKV5lNG4CVMdrPT4JEIf4DwLc8p9N_M_8P77_J0X-hv_HPiSqyVSd1SKhJi0rzjlWaZ2MTSaLfboX1JdlKnMqUKYo-g7TLC2UrEWiG-SIKXJMq2yf1TssqqLkNcleqLwuiOWcJqHNzpi3aef8kOgQZmqKOuN5YkRHJqwWQ1wqWHZwp6inba8DQ1zM55sl-dDNQ2A5NzrE8Bsw6mioWUUXVt335GIQ6-4Y8OX5NZm9acYYT2H5l9gybAcdx7nbSTcxbNe5zq-Hk3ffSEaG7UojMGxXJr8CAAD__5G-P2g">