[llvm-bugs] [Bug 45701] New: Failure to optimize out module before rotate
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 27 10:02:34 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45701
Bug ID: 45701
Summary: Failure to optimize out module before rotate
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: gabravier at gmail.com
CC: llvm-bugs at lists.llvm.org
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 https://godbolt.org/z/zcYUbK)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200427/3f360436/attachment.html>
More information about the llvm-bugs
mailing list