<html>
<head>
<base href="https://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 --- - Missed optimization for explicit little-endian loads" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24057&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=AJaQDVmnLc-h_BM-TYqKIcRGx8zVTE8GGt2ygCWlgUE&s=PiNFEdXuAKPx-ZRzJ8wJlFoQusTXV0oR_A7T3hxQKC0&e=">24057</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed optimization for explicit little-endian loads
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.5
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>luto@mit.edu
</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>--- begin code ---
struct eightbytes {
unsigned char bytes[8];
} __attribute__((aligned(8)));
unsigned long long load_le64(const struct eightbytes *p)
{
return ((unsigned long long)p->bytes[0] |
(unsigned long long)p->bytes[1] << 8 |
(unsigned long long)p->bytes[2] << 16 |
(unsigned long long)p->bytes[3] << 24 |
(unsigned long long)p->bytes[4] << 32 |
(unsigned long long)p->bytes[5] << 40 |
(unsigned long long)p->bytes[6] << 48 |
(unsigned long long)p->bytes[7] << 56);
}
--- end code ---
GCC 5.1.1 (and 5.0 as well, I think) generates the obvious optimized code for
load_le64. In fact, GCC 5.1.1 also gets the big-endian version right. clang
generates a bunch of zero-extending loads, shifts, and ors.
Given that this more or less the canonical way of writing portable
serialization/deserialization code without relying on undefined or unspecified
behavior, it would be nice if clang generated good code for it.
Feel free to reassign from clang to LLVM if appropriate.</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>