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

    <tr>
        <th>Summary</th>
        <td>
            InstCombine should fold ldexp(x, zext(i1 y)) to fmul x, (select y, 1.0, 2.0)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            missed-optimization,
            floating-point
      </td>
    </tr>

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

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

<pre>
    ```
define float @src(float %x, i1 %bool) {
  %zext = zext i1 %bool to i32
 %ldexp = call float @llvm.ldexp.f32.i32(float %x, i32 %zext)
  ret float %ldexp
}

define float @tgt(float %x, i1 %bool) {
  %select = select i1 %bool, float 1.000000e+00, float 2.000000e+00
  %mul = fmul float %x, %select
  ret float %mul
}
```

I noticed the pattern while looking at builtin math library code 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUUtFyozoM_Rrzoglj5LjAAw9tMpnpZxgQ4HsNzmCx2_Trd-zQZrvbl81ksCzLOj46x4Rgx4WoEfpF6HNmNp782pg10DJnre9vjXiS-1-ehXzuabALweC8YRBHGdZOYLVvUb8JPIEtYth67wTWIMqX-1WI2Xd6YxDqDCl4VAJ7sAr3SoHa9fR2TZWdce4B6NyPOU-H-aAwj3f-wlf4ASWw_gBfieGzLjW4n4jyvAffEuSR_4lgIEfdneIe_l592hsXuUw_Evgi5SOPX_OPtvPmUs8hBl9f8wn6LdN5c3_y_Kro_fsKi2fbUQ88EVwNM60L_JysI3De_2-XEQxDu1nHdoHZ8ATOtqtZb9D5niDrG9XXqjYZNUVZ6FoXpSyzqamrVrdPuipL7Ipel4NSRyRsK6rKupMysw1KPEpdlIUqtCzz-kkPfdV1R4Ul1eoojpJmY12etPfrmNkQNmpq1KrKnGnJheRgxNmGQP3BX9nO9t2w9YtAFHgSiGkkdhkPV28Xjml9ztYmNj202xiiuWzg8IBhy46a1yXwyc9ttEWY_OZ6GLzr4e4hrJIId7NVtoBb9BzW0dBJrF2janfDLW6LPGmOcamzbXXNxHwNQj0LvAi8jJanrc07Pwu8xOfsy-G6-v-i0nhJIwgCL2kKvwIAAP__zp4dXQ">