[llvm-bugs] [Bug 39657] New: suboptimal address calculation for aarch64
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 13 19:33:10 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39657
Bug ID: 39657
Summary: suboptimal address calculation for aarch64
Product: new-bugs
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: froydnj at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
This hackish code was extracted from some real code that was attempting to be
clever:
int f(char* p, long x)
{
int i;
__builtin_memcpy(&i, (int*)(p + (-x - 1)*4), sizeof(i));
return i;
}
clang -O2 trunk generates, according to gcc.godbolt.org:
lsl x8, x1, #2
eor x8, x8, #0xfffffffffffffffc
ldr w0, [x0, x8]
ret
whereas the preferred code would be (GCC 6.3.0, according to gcc.godbolt.org):
mvn x1, x1
ldr w0, [x0, x1, lsl 2]
ret
where the shift has been folded into the load instruction.
The same phenomenon is visible on x86-64. clang:
shlq $2, %rsi
xorq $-4, %rsi
movl (%rdi,%rsi), %eax
retq
GCC:
notq %rsi
movl (%rdi,%rsi,4), %eax
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/20181114/8a0f3c30/attachment.html>
More information about the llvm-bugs
mailing list