[llvm-bugs] [Bug 32160] New: [x86, SSE] poor codegen splatting from illegal truncated vector type

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 6 16:11:09 PST 2017


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

            Bug ID: 32160
           Summary: [x86, SSE] poor codegen splatting from illegal
                    truncated vector type
           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: llvm-bugs at lists.llvm.org

This is fallout noted by Eli from the proposed InstCombine in: 
https://reviews.llvm.org/D30123 

define <8 x i16> @narrow_splat1(<8 x i32> %x) {
  %shuf = trunc <8 x i32> %x to <8 x i16>
  %trunc = shufflevector <8 x i16> %shuf, <8 x i16> undef, <8 x i32> <i32 2,
i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2>
  ret <8 x i16> %trunc
}

$ ./llc -o - widesplat.ll 
        pslld   $16, %xmm1
        psrad   $16, %xmm1
        pslld   $16, %xmm0
        psrad   $16, %xmm0
        packssdw        %xmm1, %xmm0
        pshuflw $170, %xmm0, %xmm0      ## xmm0 = xmm0[2,2,2,2,4,5,6,7]
        pshufd  $80, %xmm0, %xmm0       ## xmm0 = xmm0[0,0,1,1]
        retq


Something (demandedbits?) should tell us that %xmm1 isn't necessary here.

This could have been (if the shuffle was before the trunc):
        pshufd  $170, %xmm0, %xmm0      ## xmm0 = xmm0[2,2,2,2]
        pslld   $16, %xmm0
        psrad   $16, %xmm0
        packssdw        %xmm0, %xmm0
        retq

Or some combination of pslldq + pshuflw + pshufhw?


The DAG looks like this before any x86 shuffling kicks in:
          t2: v4i32,ch = CopyFromReg t0, Register:v4i32 %vreg0
          t4: v4i32,ch = CopyFromReg t0, Register:v4i32 %vreg1
        t5: v8i32 = concat_vectors t2, t4
      t6: v8i16 = truncate t5
    t8: v8i16 = vector_shuffle<2,2,2,2,2,2,2,2> t6, undef:v8i16

-- 
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/20170307/3f0211c4/attachment.html>


More information about the llvm-bugs mailing list