<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [AVX512] Masked instruction selection gets confused by bitcasts"
   href="https://llvm.org/bugs/show_bug.cgi?id=26762">26762</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AVX512] Masked instruction selection gets confused by bitcasts
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Creating a VPMOVZX by zero extend and then masking it correctly creates a
masked instruction:

define <16 x i16> @zext_mask_16x8_to_16x16(<16 x i8> %a, <16 x i1> %mask) {
  %ext = zext <16 x i8> %a to <16 x i16>
  %ret = select <16 x i1> %mask, <16 x i16> %ext, <16 x i16> zeroinitializer
  ret <16 x i16> %ret
}

  vpsllw    $7, %xmm1, %xmm1
  vpmovb2m    %xmm1, %k1
  vpmovzxbw    %xmm0, %ymm0 {%k1} {z}
  retq

But creating a VPMOVZX by a bitcasted shuffle fails to merge the mask:

define <16 x i16> @zext_mask_16x8_to_16x16(<16 x i8> %a, <16 x i1> %mask) { 
  %x   = shufflevector <16 x i8> %a, <16 x i8> zeroinitializer, <32 x i32> <i32
0, i32 16, i32 1, i32 16, i32 2, i32 16, i32 3, i32 16, i32 4, i32 16, i32 5,
i32 16, i32 6, i32 16, i32 7, i32 16, i32 8, i32 16, i32 9, i32 16, i32 10, i32
16, i32 11, i32 16, i32 12, i32 16, i32 13, i32 16, i32 14, i32 16, i32 15, i32
16>
  %bc  = bitcast <32 x i8> %x to <16 x i16>
  %ret = select <16 x i1> %mask, <16 x i16> %bc, <16 x i16> zeroinitializer
  ret <16 x i16> %ret
}

  vpsllw    $7, %xmm1, %xmm1
  vpmovb2m    %xmm1, %k1
  vpmovzxbw    %xmm0, %ymm0
  vmovdqu16    %ymm0, %ymm0 {%k1} {z}
  retq</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>