<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 --- - LLVM (Clang) failed to optimized little-endian integer composition"
href="https://llvm.org/bugs/show_bug.cgi?id=31162">31162</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLVM (Clang) failed to optimized little-endian integer composition
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>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>peetlugen19@yandex.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Clang/LLVM is unable to optimize this:
uint32_t read32le(const uint8_t* ptr) {
return (static_cast<uint32_t>(ptr[0]) & 0x000000FFu) |
((static_cast<uint32_t>(ptr[1]) << 8) & 0x0000FF00u) |
((static_cast<uint32_t>(ptr[2]) << 16) & 0x00FF0000u) |
((static_cast<uint32_t>(ptr[3]) << 24) & 0xFF000000u);
}
LLVM code:
read32le(unsigned char const*):
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
GCC (7) code:
read32le(unsigned char const*):
mov eax, DWORD PTR [rdi]
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>