<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 - Failure to optimize out module before rotate"
href="https://bugs.llvm.org/show_bug.cgi?id=45701">45701</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Failure to optimize out module before rotate
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gabravier@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>uint64_t ror64(uint64_t x, uint32_t y)
{
y %= 64;
if (y == 0)
return x;
return (x >> y) | (x << (64 - y));
}
GCC optimizes this to this :
ror64(unsigned long, unsigned int):
mov rax, rdi
mov ecx, esi
ror rax, cl
ret
LLVM does this :
ror64(unsigned long, unsigned int):
mov ecx, esi
mov rax, rdi
ror rax, cl
test cl, 63
cmove rax, rdi
ret
The test is redundant, since x86-64 `ror` will have the exact same behaviour
that the `%= 64` and the check emulate
(see also <a href="https://godbolt.org/z/zcYUbK">https://godbolt.org/z/zcYUbK</a>)</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>