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

    <tr>
        <th>Summary</th>
        <td>
            AVX2 miscompilation 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:X86,
            miscompilation
      </td>
    </tr>

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

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

<pre>
    Reported here: https://twitter.com/benjinsmith/status/1519274454798458886
```
define <2 x i64> @_Z8do_stuffPKi(ptr %0) {
  %2 = load <16 x i8>, ptr %0, align 16
  %3 = icmp eq <16 x i8> %2, zeroinitializer
  %4 = tail call <16 x i8> @llvm.x86.sse2.pavg.b(<16 x i8> zeroinitializer, <16 x i8> zeroinitializer)
  %5 = select <16 x i1> %3, <16 x i8> <i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>, <16 x i8> %4
  %6 = shufflevector <16 x i8> %5, <16 x i8> poison, <16 x i32> <i32 8, i32 8, i32 9, i32 9, i32 10, i32 10, i32 11, i32 11, i32 12, i32 12, i32 13, i32 13, i32 14, i32 14, i32 15, i32 15>
  %7 = bitcast <16 x i8> %6 to <2 x i64>
  ret <2 x i64> %7
}
declare <16 x i8> @llvm.x86.sse2.pavg.b(<16 x i8>, <16 x i8>)
```
GOOD: llc -mcpu=skx
```
do_stuff(int const*):                         # @do_stuff(int const*)
        vxorps  %xmm0, %xmm0, %xmm0
        retq
 ```
BAD: llc -mcpu=haswell
```
do_stuff(int const*):                         # @do_stuff(int const*)
        retq
```
I suspect this is a select combine issue but I haven't been able to confirm yet.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVU1vnDAQ_TXmYgWBsfk4cNhk2yrKIVUqVVEvkQ1mcWIwwWaz6a_vwG6yH2xbKVJVZIlnw3ueGXtmhClf8zvZmd7JEteylyha4Nq5zgJA5DMM96Kck71fmAZmQraPqrWNcjXMrONusABCFmYkoZTRJEspS9M0RsESBQsUB7sxTUtZqVZiFF0RvMEqpij6hBENHn6kpXmwbqiqrzcKkbRzPUaEBYhkGCWXWzYelwiwl1gbXo4yYTzqpCCDyBXes64w12rV4jA-oEYTVRVNh-XzMXtSHmk_ZW9Uq5wCPuADNp3YjiuNC671KZ8GWq8bf5PGvrWS-B1fr3wBrhz_d6oPW_7lh-zABjbZYKWWhdvzwp0D0VwNZirFnVHWtOPXfzsJPvzent_sSOiB7_HW9xruiJZrCIDp5wQ2l9lb-L4ekbfYRASnkxGHIJuBMDiDwjOInEHRGUTPIHaAIB57z5PJc6Fcwa2b-xxjZ45T6o3bS3eaa6C2y8xk-ZaThea9_Nh9noX7_b6eZP6X29vlWFy0LvBFU3QDuGSfNuerxK4UwGaqdbgwrXWILEZpUPjdg0g0Wv0H8i4q22e9MX1np_hummY61TPwiALhfN6tnFh8uZg5V3P7IrX-fw7urT3Z_RrbwXZjBXG1shgGfyspUOTFWKCVtYPEYnD4Gtd8LSF9EoeFlC3mQsvxwsG-leob_Cqd75V5VGZRxj2nnJb54vs9wY2yINcpzZ0yLfaGXufHrWUFXWQQu84y3rbd66LrzSOYA9PJkLHDMBayxKvzIAmiMEqSIqYViajIMlIlFeMVJZQVpPA0F1LbHLFLRIjgxZNsS9jxHjoSIdujJcemjets6amcBIQElKRBQmPC_ERULCwEiVgCbU0KiL1soPz7U2KYfuX1-WSuGFZ2zBdlnd1_5NZCB5JyMgX0-eBq0-d3N99UY1pv8iyf3PoFkzkKhg">