[llvm-bugs] [Bug 31470] New: <64 x i8> reverse shuffle should be optimized

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 26 05:10:52 PST 2016


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

            Bug ID: 31470
           Summary: <64 x i8> reverse shuffle should be optimized
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: elena.demikhovsky at intel.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The reverse shuffle:

define <64 x i8> @foo(<64 x i8> %src512) {
  %V512 = shufflevector <64 x i8> %src512, <64 x i8> undef, <64 x i32> <i32 63,
i32 62, i32 61, i32 60, i32 59, i32 58, i32 57, i32 56, i32 55, i32 54, i32 53,
i32 52, i32 51, i32 50, i32 49, i32 48, i32 47, i32 46, i32 45, i32 44, i32 43,
i32 42, i32 41, i32 40, i32 39, i32 38, i32 37, i32 36, i32 35, i32 34, i32 33,
i32 32, i32 31, i32 30, i32 29, i32 28, i32 27, i32 26, i32 25, i32 24, i32 23,
i32 22, i32 21, i32 20, i32 19, i32 18, i32 17, i32 16, i32 15, i32 14, i32 13,
i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2,
i32 1, i32 0>
  ret <64 x i8> %V512
}

The code, generated for skylake-AVX512:
        vmovdqu8        .LCPI0_0(%rip), %ymm1 # ymm1 =
[15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]
        vpshufb %ymm1, %ymm0, %ymm2
        vperm2i128      $1, %ymm0, %ymm2, %ymm2 # ymm2 = ymm2[2,3,0,1]
        vextracti64x4   $1, %zmm0, %ymm0
        vpshufb %ymm1, %ymm0, %ymm0
        vperm2i128      $1, %ymm0, %ymm0, %ymm0 # ymm0 = ymm0[2,3,0,1]
        vinserti64x4    $1, %ymm2, %zmm0, %zmm0

Should be done in 2 instructions:
vpshufb %zmm - reverse elements inside 128-bit lanes
vperm2i128 - put 4 128-bit lanes in reverse order

-- 
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/20161226/0a6ddb7b/attachment-0001.html>


More information about the llvm-bugs mailing list