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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Failure to convert vector fp comparisons thath can be represented as integers
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:instcombine,
            missed-optimization
      </td>
    </tr>

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

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

<pre>
    https://rust.godbolt.org/z/dfWjnToef

We will simplify a comparison of scalar floats that can be represented as integers to compare the integers directly, but we don't do this for vectors:

```ll
define i32 @cmpf(i32 %x) {
  %and = and i32 %x, 3
  %conv = sitofp i32 %and to float
  %cmp = fcmp oeq float %conv, 3.000000e+00
  %sext = sext i1 %cmp to i32
  ret i32 %sext
}

define <8 x i32> @vcmpf(<8 x i32> %x) {
  %and = and <8 x i32> %x, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
 %conv = sitofp <8 x i32> %and to <8 x float>
  %cmp = fcmp oeq <8 x float> %conv, <float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00>
  %sext = sext <8 x i1> %cmp to <8 x i32>
  ret <8 x i32> %sext
}
```
opt -O3
```ll
define i32 @cmpf(i32 %x) {
  %and = and i32 %x, 3
  %cmp = icmp eq i32 %and, 3
  %sext = sext i1 %cmp to i32
  ret i32 %sext
}

define <8 x i32> @vcmpf(<8 x i32> %x) {
  %and = and <8 x i32> %x, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %conv = sitofp <8 x i32> %and to <8 x float>
 %cmp = fcmp oeq <8 x float> %conv, <float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00>
  %sext = sext <8 x i1> %cmp to <8 x i32>
  ret <8 x i32> %sext
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVk2L3DgQ_TXypZhGljzT7YMPM-4Ylj0s7C7kLFvltoJsOVK5M5Nfv8gfO57OQA6BwLJpmna5-qlKelWFngrBXAbEgt0_sftzoibqnC_-_P0v07shqZ1-KTqiMTD5yETFROWnQIeL07WzdHD-wkT1lYlKtx8_DX87bBk_M_64_H5E-GKshWD60Zr2BRQ0rh-VN8EN4FoIjbLKQ2udogDUKYJGDVAjeBw9BhwINagAZiC8oA9Abg2BQB2--rXx2JB9YaKEeiL4gqDdwMSRQDugzgRonYcrNuT8fJrdPtkDX77WLg6NrRkQjBTAMt70Y8vEaX4T989M5MCOTwsSoksNGpg8Q3y-okqQO0zjhusMCoZcO264uITcwsAe3Y8zuI2Gw88LYIszxz7w-YNMPHG-WxrwmZZE0TDpFo5czLkBPdK2hYhbeTie97SsLDBZnuB5Xiw_RD6uKyE3f3yXmvfwZfTGjcho_4ghP6xp3yH7m8wr7at_Yf_fAO8W4Aa6LwWT5VKem5qIEv4T_jcHf9s-G3HpduSlkd7wuW-pb4h-r7m2aVte3Uhw94f8iZO4ltZEAz_vJvEW-b8fpR-fpV-j9FNGKdGF1LnMVYJFeuQnmWUPMk-6QqW8yVSTPshaP3B9ylNxzKVu8ZSelNZNYgrBRcZFmqci5TI_tO2x5Vkmc5ly2aBgGcdeGXuw9trHGz8xIUxYnITI0sSqGm2Y5YMQEcHkoxkCNa6vzYBMCCZKJkRvQkB950YyvfmqyMTLWUTJ4Yu47K6eLoFl3JpA4TUVGbKzOPltCFSuMe_PUCljp6gBohwYruhpvdqhHXcaY9EU3XdERTJ5e6NyLoa6qT40rmeimo-1PO5G7z5hQ0xUMwuBiWom4p8AAAD__35Sh54">