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

    <tr>
        <th>Summary</th>
        <td>
            [InstSimplify] Miscompile with select of vectors and bitcast
        </td>
    </tr>

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

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

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

<pre>
    https://alive2.llvm.org/ce/z/xhCFyk

```llvm
define <4 x i32> @src(<2 x i64> %x, <4 x i32> %y) {
  %x.bc = bitcast <2 x i64> %x to <4 x i32>
  %y.bc = bitcast <4 x i32> %y to <2 x i64>
  %sub = sub <2 x i64> %x, %y.bc
  %sub.bc = bitcast <2 x i64> %sub to <4 x i32>
  %cmp = icmp eq <4 x i32> %y, %x.bc
  %sel = select <4 x i1> %cmp, <4 x i32> %sub.bc, <4 x i32> zeroinitializer
  ret <4 x i32> %sel
}

define <4 x i32> @tgt(<2 x i64> %x, <4 x i32> %y) {
  ret <4 x i32> zeroinitializer
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVN1unDwQfZrhxsrKDAZ2L7hI2A_pu-hVn8AYs0xjMMUmzebpK_66m4S2UiWE0XjOzJnROUjn6NJpnUH8BIgdPZMCRIjPgRx9Y4dsDgWlra5Z433vIHoELAALaehF48GYl_ZghwtgoTRg8QZYvDZ5cX0Gfgb-uL4TvjxT-hKqdE2dZhDlgr0yihCi_xgI7gYFeIQoxymciDmM8Stg_jEZ4yvgiUH6tJRkc-KhVAyiMyvJK-k8-1yKefu-1B38ugP_0HOF34rewd1Yzujl3J1h6fEe81fOU70_sFZtP-Np-tDfdxeVb9u5b63NQlcbrW6zhitKtf3u2hfGn6_e9GCpI0_S0JsetkaD3lmj02bVRnq-l8rvdOEv_t918ZnBLtUblU2vQZVF1Sk6yUBnYcpFijEXcdBkScJjVMdQcl6FGJanJI3roxRYCyWqUxxQhhwFD_kxFELw-BBxqYRSSZgea1mFIQiuW0nml4UCcm7UWZpGyAMjS23c6suWnLJtT0Z6st1kUMwBcTZT9Eid88q2JXV69e6QTVcP5XhxILgh592tiydvZsP_3zn_ldreUH2F-My-bF00-0G-2URha_ailbeDY7KrNokG42A-_BEu5JuxPCjbAhYzt-V46Af7TSsPWMwTOsBiHvJnAAAA__9i8T-d">