[llvm-bugs] [Bug 32865] New: [InstCombine] hoist vector cast above splat as scalar cast?

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 1 08:51:16 PDT 2017


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

            Bug ID: 32865
           Summary: [InstCombine] hoist vector cast above splat as scalar
                    cast?
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

Forking this off from bug 14657.

One of these should be canonical:

define <8 x i32> @sext_last(i16 %x) {
  %ins = insertelement <8 x i16> undef, i16 %x, i32 0
  %splat = shufflevector <8 x i16> %ins, <8 x i16> undef, <8 x i32>
zeroinitializer
  %sext = sext <8 x i16> %splat to <8 x i32>
  ret <8 x i32> %sext
}

define <8 x i32> @sext_first(i16 %x) {
  %sext = sext i16 %x to i32
  %ins = insertelement <8 x i32> undef, i32 %sext, i32 0
  %splat = shufflevector <8 x i32> %ins, <8 x i32> undef, <8 x i32>
zeroinitializer
  ret <8 x i32> %splat
}

We may need to prepare the backend to expect the canonical pattern to avoid
regressions. Eg, with AVX1, there's a big difference in codegen:

$ ./llc -o - splatsext.ll -mattr=avx
_sext_last:                             ## @sext_last
        vmovd   %edi, %xmm0
        vpshuflw        $0, %xmm0, %xmm0 ## xmm0 = xmm0[0,0,0,0,4,5,6,7]
        vpshufd $80, %xmm0, %xmm0       ## xmm0 = xmm0[0,0,1,1]
        vpmovsxwd       %xmm0, %xmm1
        vpshufd $78, %xmm0, %xmm0       ## xmm0 = xmm0[2,3,0,1]
        vpmovsxwd       %xmm0, %xmm0
        vinsertf128     $1, %xmm0, %ymm1, %ymm0

_sext_first:                            ## @sext_first
        movswl  %di, %eax
        vmovd   %eax, %xmm0
        vpshufd $0, %xmm0, %xmm0        ## xmm0 = xmm0[0,0,0,0]
        vinsertf128     $1, %xmm0, %ymm0, %ymm0

-- 
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/20170501/d142d71e/attachment.html>


More information about the llvm-bugs mailing list