[llvm-bugs] [Bug 39549] New: [X86] SimplifyDemandedBits fails to remove a zero vector input from unpckh

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Nov 3 09:07:51 PDT 2018


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

            Bug ID: 39549
           Summary: [X86] SimplifyDemandedBits fails to remove a zero
                    vector input from unpckh
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: craig.topper at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

For this IR sequence

define <8 x i16> @foo(<16 x i8> %x) {
  %a = shufflevector <16 x i8> %x, <16 x i8> undef, <16 x i32> <i32 8, i32
undef, i32 9, i32 undef, i32 10, i32 undef, i32 11, i32 undef, i32 12, i32
undef, i32 13, i32 undef, i32 14, i32 undef, i32 15, i32 undef>
  %b = bitcast <16 x i8> %a to <8 x i16>
  %c = shl <8 x i16> %b, <i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16
8>
  %d = ashr <8 x i16> %c, <i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16
8>
  ret <8 x i16> %d
}

We generate this assembly

        pxor    %xmm1, %xmm1
        punpckhbw       %xmm0, %xmm1    ## xmm1 =
xmm1[8],xmm0[8],xmm1[9],xmm0[9],xmm1[10],xmm0[10],xmm1[11],xmm0[11],xmm1[12],xmm0[12],xmm1[13],xmm0[13],xmm1[14],xmm0[14],xmm1[15],xmm0[15]
        psraw   $8, %xmm1


But the pxor is unnecessary. The elements being zeroed aren't consumed by the
psraw. We could just use %xmm0 for both inputs of the unpckh.

Even D54069 which adds SimplifyDemandedBits support for X86ISD::VPSRAI doesn't
help with this.

-- 
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/20181103/fdbaaea4/attachment.html>


More information about the llvm-bugs mailing list