[llvm-bugs] [Bug 44796] New: Use movzx instead of mov + shr

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 5 04:30:41 PST 2020


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

            Bug ID: 44796
           Summary: Use movzx instead of mov + shr
           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

unsigned char sum2(const void* ptr)
{
    const unsigned k = 2;
    unsigned char bytes[k], result = 0;
    memcpy(bytes, ptr, k);
    for(unsigned n=0; n<k; ++n) result += bytes[n];
    return result;
}

GCC:
sum2(void const*):
  movzx edx, WORD PTR [rdi]
  movzx eax, dh
  add eax, edx
  ret

Clang:
sum2(void const*): # @sum2(void const*)
  movzx ecx, word ptr [rdi]
  mov eax, ecx
  shr eax, 8
  add al, cl
  ret


https://godbolt.org/z/dTuEJb

-- 
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/20200205/3da0fef8/attachment-0001.html>


More information about the llvm-bugs mailing list