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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
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._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs