[llvm-bugs] [Bug 40434] New: [x86] shuffle lowering should try harder to match unpack

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 24 04:09:19 PST 2019


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

            Bug ID: 40434
           Summary: [x86] shuffle lowering should try harder to match
                    unpack
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

define <8 x i32> @shuf_unpack(<8 x i32> %x, <8 x i32> %y) {
  %unpckh = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 2, i32 14,
i32 3, i32 15, i32 undef, i32 undef, i32 undef, i32 undef>
  ret <8 x i32> %unpckh
}

This translates to what I think is the optimal extract+unpckhps with AVX1:

$ llc -o - unpckh.ll -mattr=avx
        vextractf128    $1, %ymm1, %xmm1
        vunpckhps       %xmm1, %xmm0, %xmm0 ## xmm0 =
xmm0[2],xmm1[2],xmm0[3],xmm1[3]
        retq


But with AVX2, the availability of more shuffle instructions leads to a worse
outcome:

$ llc -o - unpckh.ll -mattr=avx2
        vblendps        $192, %ymm1, %ymm0, %ymm0 ## ymm0 =
ymm0[0,1,2,3,4,5],ymm1[6,7]
        vmovaps LCPI0_0(%rip), %ymm1    ## ymm1 = <2,6,3,7,u,u,u,u>
        vpermps %ymm0, %ymm1, %ymm0
        retq

-- 
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/20190124/bd440e91/attachment.html>


More information about the llvm-bugs mailing list