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: unassignedb...@nondot.org
Reporter: gabrav...@gmail.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs