[llvm-bugs] [Bug 34686] New: [X86][SSE] extra pshufhw generated in simple shuffle code

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 20 09:25:09 PDT 2017


            Bug ID: 34686
           Summary: [X86][SSE] extra pshufhw generated in simple shuffle
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: cox2 at cooper.edu
                CC: llvm-bugs at lists.llvm.org

Trunk turns these two shuffles into three (The commented out line is equivalent
and generates the same 3 shuffles):

#include <emmintrin.h>
__m128i m(__m128i i) {
    const __m128i a = _mm_shufflelo_epi16(i, 0x14);
    return _mm_shuffle_epi32(a, 0x44);
    // return _mm_unpacklo_epi64(a, a);

clang -S -O3 test.c -o -
        pshufd  $196, %xmm0, %xmm0      # xmm0 = xmm0[0,1,0,3]
        pshuflw $20, %xmm0, %xmm0       # xmm0 = xmm0[0,1,1,0,4,5,6,7]
        pshufhw $20, %xmm0, %xmm0       # xmm0 = xmm0[0,1,2,3,4,5,5,4]

This can be observed at all optimization levels above 0.

I'd expect the same output that gcc generates:
gcc -S -O3 test.c -o -
        pshuflw $20, %xmm0, %xmm0
        pshufd  $68, %xmm0, %xmm0

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/20170920/bb62efd7/attachment.html>

More information about the llvm-bugs mailing list