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

    <tr>
        <th>Summary</th>
        <td>
            InstCombine should fold frexp of select to select of frexp
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            good first issue,
            llvm:instcombine,
            missed-optimization,
            floating-point
      </td>
    </tr>

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

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

<pre>
    If one of the select operands is a constant, we generally push operations through to select on the result.

```
define float @src(float %x, i1 %bool) {
  %select = select i1 %bool, float 1.000000e+00, float %x
 %frexp = tail call { float, i32 } @llvm.frexp.f32.i32(float %select)
 %frexp.0 = extractvalue { float, i32 } %frexp, 0
  ret float %frexp.0
}

define float @tgt(float %x, i1 %bool) {
  %frexp = tail call { float, i32 } @llvm.frexp.f32.i32(float %x)
  %frexp.0 = extractvalue { float, i32 } %frexp, 0
  %select = select i1 %bool, float 5.000000e-01, float %frexp.0
  ret float %select
}

```

This case is somewhat complicated by the extractvalue. The combine should be rooted at a hasOneUse extractvalue (frexp), 0 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVFGPozgM_jXhxSoKBrblgYeZqSrt073s_YAABnIKBMVht3O__pRAp53qTrqVpqrSJrE_29_nWDHrYSaqRfkqynOiVj9aVyvHNE9JY7v3-nsPdiawPfiRgMlQ68Eu5NTcMWgGBa2d2avZC3yDXwQDzeSUMe-wrDxutl7bmcGPzq7DCN5-AM0R1hGvxqdCnoV82ddvcv_GbUe9ngl6Y5UHUUh2rcDTvsXyGmLrLPxtrDUCKxDH180VwukeT-TnW-hH67cdOEtl_JDAVynv5zHCBiaw7B1dlwjllTbQKmNCtM02JpIjiOM55GnMzymNDmmfY6pzfEx7S0Vg9QSeyghPV-9U638qs9J_RNgdwpm8levI3_Pe8XZSj-dHjp9J9YP_LVK_jojrnYMvIuF_a17eND_I7JPin5h7YnUX7t9IfWrcbf0xaoZWMYUXw3aiX6Py0NppMbpVnjpo3uNLeKw2hR8jBaMmqMSjXU0HDYGzNngoDwpGxX_M9CfTE0942impIiuQdHXeVXmlEqqzY1ZWJRanKhnrXmVNWTQqLxqJp65qO8yytsjzrJFFUVGia5RYyDI7ZjmeZJU2RXWqiu7UHYv2W4W5KCRNSps0SmzdkGjmleoKywIToxoyHAcM4mBtB7127CHaCESBbwIxuIr8Rc_s93o_ribNTN3BLl5P-u84ST7uoh56Hg6L1WH-YBhirg5oh2YdOPSdZs_31Lz2hurvM_u3z7z2NiyxoW1_65eHQdVvl8nqTD16v7DIXwReBF4G7ce1SVs7CbzEQrafw-LsX_F5X2KxLPASOfknAAD__4lvqdk">