<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - performance: deduce least significant bits of a pointer from alignment"
href="http://llvm.org/bugs/show_bug.cgi?id=20971">20971</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>performance: deduce least significant bits of a pointer from alignment
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>kcc@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Here is a small performance opportunity:
struct S {
long x; // 8-aligned
int a, b;
};
unsigned long a_bits(S *s) {
return reinterpret_cast<unsigned long>(&s->a) & 7;
}
unsigned long b_bits(S *s) {
return reinterpret_cast<unsigned long>(&s->b) & 7;
}
s->a is known to be 0 mod 8, and s->b to be 4 mod 8.
Gcc uses it to optimize the code:
a_bits:
xorl %eax, %eax
ret
b_bits:
movl $4, %eax
ret
Clang does not:
a_bits:
leal 8(%rdi), %eax
andq $7, %rax
retq
b_bits:
leal 12(%rdi), %eax
andq $7, %rax
retq
Such optimization applied after ASAN instrumentation will reduce asan overhead,
see <a href="https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg88631.html">https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg88631.html</a>
It's probably better to implement it as a separate thing than trying to
make this optimization specifically in asan.
Thoughts?</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>