[llvm-bugs] [Bug 46281] New: Improve codegen for shift by constant

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 11 06:18:08 PDT 2020


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

            Bug ID: 46281
           Summary: Improve codegen for shift by constant
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky 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

typedef char v16qi __attribute__ ((vector_size (16)));
typedef char v32qi __attribute__ ((vector_size (32)));

v16qi ashiftrt (v16qi a)
{
    return  a>>5;
}

v32qi arshiftrt2 (v32qi a)
{
    return  a>>5;
}


Clang -g0  -O3 -march=skylake

.LCPI0_0:
        .zero   16,7
.LCPI0_1:
        .zero   16,4
ashiftrt(char __vector(16)):                      # @ashiftrt(char
__vector(16))
        vpsrlw  xmm0, xmm0, 5
        vpand   xmm0, xmm0, xmmword ptr [rip + .LCPI0_0]
        vmovdqa xmm1, xmmword ptr [rip + .LCPI0_1] # xmm1 =
[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
        vpxor   xmm0, xmm0, xmm1
        vpsubb  xmm0, xmm0, xmm1
        ret
.LCPI1_0:
        .zero   32,7
.LCPI1_1:
        .zero   32,4
arshiftrt2(char __vector(32)):                   # @arshiftrt2(char
__vector(32))
        vpsrlw  ymm0, ymm0, 5
        vpand   ymm0, ymm0, ymmword ptr [rip + .LCPI1_0]
        vmovdqa ymm1, ymmword ptr [rip + .LCPI1_1] # ymm1 =
[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
        vpxor   ymm0, ymm0, ymm1
        vpsubb  ymm0, ymm0, ymm1
        ret


ICC -g0  -O3 -march=skylake

ashiftrt(char __vector(16)):
        vpsrlw    xmm1, xmm0, 5                                 #6.16
        vpand     xmm0, xmm1, XMMWORD PTR .L_2il0floatpacket.0[rip] #6.16
        ret                                                     #6.16
arshiftrt2(char __vector(32)):
        vpsrlw    ymm1, ymm0, 5                                 #11.16
        vpand     ymm0, ymm1, YMMWORD PTR .L_2il0floatpacket.1[rip] #11.16
        ret                                                     #11.16
.L_2il0floatpacket.1:
        .long  
0x07070707,0x07070707,0x07070707,0x07070707,0x07070707,0x07070707,0x07070707,0x07070707
.L_2il0floatpacket.0:
        .long   0x07070707,0x07070707,0x07070707,0x07070707



Godbolt: https://godbolt.org/z/LAibFf

-- 
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/20200611/718b5130/attachment-0001.html>


More information about the llvm-bugs mailing list