[llvm-bugs] [Bug 31364] New: [x86] Bad lowering of _mm_shuffle_epi8

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 13 12:30:41 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=31364

            Bug ID: 31364
           Summary: [x86] Bad lowering of _mm_shuffle_epi8
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: efriedma at codeaurora.org
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161213/89ae9b19/attachment.html>


More information about the llvm-bugs mailing list