[llvm-bugs] [Bug 33498] New: Can't coalesce four consecutive byte loads into a single x86 mov
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jun 18 13:43:37 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33498
Bug ID: 33498
Summary: Can't coalesce four consecutive byte loads into a
single x86 mov
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: justin.lebar at gmail.com
CC: llvm-bugs at lists.llvm.org, mkuper at google.com
Consider
unsigned foo(unsigned char* d) {
return (static_cast<unsigned int>(d[0]) << 0) |
(static_cast<unsigned int>(d[1]) << 8) |
(static_cast<unsigned int>(d[2]) << 16) |
(static_cast<unsigned int>(d[3]) << 24);
}
gcc 5.1+ compiles this as
mov eax, DWORD PTR [rdi]
ret
but clang 4.0 -O2 naively does a series of shifts bitwise ORs:
movzx eax, byte ptr [rdi]
movzx ecx, byte ptr [rdi + 1]
shl ecx, 8
or ecx, eax
movzx edx, byte ptr [rdi + 2]
shl edx, 16
or edx, ecx
movzx eax, byte ptr [rdi + 3]
shl eax, 24
or eax, edx
ret
I'll test on clang at HEAD in a few minutes once I get a build up and running.
--
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/20170618/c11f7ebb/attachment.html>
More information about the llvm-bugs
mailing list