<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 --- - [x86] Bad lowering of _mm_shuffle_epi8"
   href="https://llvm.org/bugs/show_bug.cgi?id=31364">31364</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[x86] Bad lowering of _mm_shuffle_epi8
          </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>Windows NT
          </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>efriedma@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Testcase:

#include <immintrin.h>
__m128i pshufb_const(char *a, char *b) {
  const __m128i x = _mm_insert_epi8(_mm_insert_epi8(_mm_setzero_si128(), *a,
0), *b, 1);
  __m128i m = _mm_set_epi8(0, 0, 0, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1);
  return _mm_shuffle_epi8(x, m);
}
__m128i pshufb_var(char *a, char *b, __m128i m) {
  const __m128i x = _mm_insert_epi8(_mm_insert_epi8(_mm_setzero_si128(), *a,
0), *b, 1);
  return _mm_shuffle_epi8(x, m);
}

Generated code for pshufb_const (clang -O2 -mavx):
        movzbl  (%rsi), %eax
        vmovd   %eax, %xmm0
        vpinsrb $1, %eax, %xmm0, %xmm0
        vpinsrb $2, %eax, %xmm0, %xmm0
        vpinsrb $3, %eax, %xmm0, %xmm0
        vpinsrb $4, %eax, %xmm0, %xmm0
        vpinsrb $5, %eax, %xmm0, %xmm0
        vpinsrb $6, %eax, %xmm0, %xmm0
        xorl    %ecx, %ecx
        vpinsrb $7, %ecx, %xmm0, %xmm0
        vpinsrb $8, %eax, %xmm0, %xmm0
        vpinsrb $9, %eax, %xmm0, %xmm0
        vpinsrb $10, %eax, %xmm0, %xmm0
        vpinsrb $11, %eax, %xmm0, %xmm0
        vpinsrb $12, %eax, %xmm0, %xmm0
        movzbl  (%rdi), %eax
        vpinsrb $13, %eax, %xmm0, %xmm0
        vpinsrb $14, %eax, %xmm0, %xmm0
        vpinsrb $15, %eax, %xmm0, %xmm0
        retq

Generated code for pshufb_var (clang -O2 -mavx):
        vpxor   %xmm1, %xmm1, %xmm1
        vpinsrb $0, (%rdi), %xmm1, %xmm1
        vpinsrb $1, (%rsi), %xmm1, %xmm1
        vpshufb %xmm0, %xmm1, %xmm0
        retq

SelectionDAG is throwing away the shuffle in favor of a BUILD_VECTOR, and
failing to recover in a reasonable manner later on.</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>