<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - suboptimal address calculation for aarch64"
href="https://bugs.llvm.org/show_bug.cgi?id=39657">39657</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>suboptimal address calculation for aarch64
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>froydnj@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>