[llvm-bugs] [Bug 51978] New: Missing reduction add for vector(4) char

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 27 01:55:20 PDT 2021


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

            Bug ID: 51978
           Summary: Missing reduction add for vector(4) char
           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

void foo_notvectorized(unsigned char *p, unsigned char *t) {
  char sum = 0;
  for (int i = 0; i != 4; i++)
    sum += p[i];
  *t = sum;
}

char foo_vectorized(char *p) {
  char sum = 0;
  for (int i = 0; i != 4; i++)
    sum += p[i];
  return sum;
}

foo_notvectorized:                      # @foo_notvectorized
        mov     al, byte ptr [rdi + 1]
        add     al, byte ptr [rdi]
        add     al, byte ptr [rdi + 2]
        add     al, byte ptr [rdi + 3]
        mov     byte ptr [rsi], al
        ret
foo_vectorized:                         # @foo_vectorized
        movd    xmm0, dword ptr [rdi]           # xmm0 = mem[0],zero,zero,zero
        pxor    xmm1, xmm1
        psadbw  xmm1, xmm0
        movd    eax, xmm1
        ret

-- 
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/20210927/580d6605/attachment.html>


More information about the llvm-bugs mailing list