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

    <tr>
        <th>Summary</th>
        <td>
            Ineffectual bitwise or with constant emitted for mask operand of vperm(b|w|d|q|ps|pd)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          cvijdea-bd
      </td>
    </tr>
</table>

<pre>
    Same thing as https://github.com/llvm/llvm-project/issues/106256, but also happens for the (avx2/avs512) permute[x]var intrinsics, while the PR https://github.com/llvm/llvm-project/pull/106377 seems to only fix it for pshufb specifically.

Godbolt examples: https://godbolt.org/z/MsTcx7qYc

The vector shuffle intrinsics ignore all bits except the ones that match the required index size, e.g.:
- vpermb only uses 4, 5, 6 bits out of each mask byte element for 128, 256, 512 bit sized vectors respectively
- vpermw only uses 3, 4, 5 bits out of each 16-bit element in the mask
- etc.

The OR operations with unrelated bits should be optimzied out.

Probably applies to vpermt2 (e.g. _mm512_permutex2var_epi16) also.

cc @RKSimon 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVEtv4zYQ_jXUZRBDop4-6LDrhYuiKLrI7qWngI-RxS1FKuRItvPrC0oJmmxPRS80YJHfix9HxGguDrFn9WdWf8nEQqMPvVrND43iQepMen3vv4kJgUbjLiAijERzZOUnxs-Mny-GxkUelJ8YP1u7vv08zMH_QEWMn02MC0bGz0Xe8Lph_ARyIRA2ehjFPKOLMPgANCIw3on1xhk_izXWBWf8CDOGaSFk9ecbq7-sIoBxFIyLRsUEdh2Nxe3018f_rm5erN21lW0LEXGKQB68s3cYzA0MbeLmOC6DhDijMoNRwtr7geVfWP5pX3_xWnpLgDcxzRaThJ-17DsOPlwYP78wfv49fle39vlP9R7o-4iwoiIfIFEOFt_ZBXNxPiAIa0EaioA3hTNt5r3DCDQKgkmQGrf_Aj4vJqAG4zTeIJoXTInh4XJIujbCB1hTwnK3vESMUKVNdVqancYvBH4AFGqEScS_QN4JAS1O6PZ8Ct6l_a_3Wxc8HdwI9audCAFTfGRWtPcP3Nd33GU6vwv4N3fRPCTYN2LjNpdJ0Rsekjr8HOcfj-BnDIKMdxGuhkZYXEArCPXOEUe_WA0Swc9kpheDOvF-QPoavBTS3kHMszW4tWRTTzzVNmUKT9NUF_zptbE3vorwhLMpmtTjVPgPiEoBq_LH376ZyTvIdF_qY3kUGfZFy6uuKZq2ysa-Vp2upOqGssy7Y1lyUVb8qFVbFY3MlcpMz3Ne5R3viqaoyurQtpjnVS1a3TUoBWdVjpMw9pC6nwqYbW-yL_KmKsrMCok2bkOAc4dX2L4yztNMCP32YORyiazKrYkU_4EhQxb7Xx0OAypaxNbKq4kIPuxBK-8iCUeAk6GUdyrLVqHtSpxOd7vFyHgnWXu6svakWXt6Zu1pjmnRjB-zJdj-f02eZHTt-d8BAAD__6oUnCo">