[llvm-bugs] [Bug 47450] New: Missed vectorization (trunk vs 10)

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 7 10:16:45 PDT 2020


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

            Bug ID: 47450
           Summary: Missed vectorization (trunk vs 10)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

unsigned int output[8];

void test4 (unsigned short *p)
{
  unsigned int x = *p;
  if (x)
    {   
      output[0] = x << 1;
      output[1] = x << 1;
      output[2] = x << 1;
      output[3] = x << 1;
    }
}


Clang trunk -O3:
test4(unsigned short*):                             # @test4(unsigned short*)
        movzx   eax, word ptr [rdi]
        test    eax, eax
        je      .LBB0_2
        add     eax, eax
        mov     dword ptr [rip + output], eax
        mov     dword ptr [rip + output+4], eax
        mov     dword ptr [rip + output+8], eax
        mov     dword ptr [rip + output+12], eax
.LBB0_2:
        ret
output:
        .zero   32


Clang 10.1 -O3:
test4(unsigned short*):                             # @test4(unsigned short*)
        movzx   eax, word ptr [rdi]
        test    eax, eax
        je      .LBB0_2
        movd    xmm0, eax
        pshufd  xmm0, xmm0, 0           # xmm0 = xmm0[0,0,0,0]
        pslld   xmm0, 1
        movdqa  xmmword ptr [rip + output], xmm0
.LBB0_2:
        ret
output:
        .zero   32

ICC/GCC -O3:
test4(unsigned short*):
        movzx     eax, WORD PTR [rdi]                           #5.21
        test      eax, eax                                      #6.7
        je        ..B1.3        # Prob 50%                      #6.7
        add       eax, eax                                      #8.24
        movd      xmm0, eax                                     #8.24
        pshufd    xmm1, xmm0, 0                                 #8.24
        movdqu    XMMWORD PTR output[rip], xmm1                 #8.7
..B1.3:                         # Preds ..B1.1 ..B1.2
        ret                                                     #13.1
output:
        .zero   32


It would be good to match icc's codegen.

https://godbolt.org/z/n9a59P

-- 
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/20200907/90d1e16d/attachment-0001.html>


More information about the llvm-bugs mailing list