[llvm-bugs] [Bug 35487] New: Poor code generation for rotates
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Nov 30 16:02:24 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35487
Bug ID: 35487
Summary: Poor code generation for rotates
Product: libraries
Version: 5.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: fabiang at radgametools.com
CC: llvm-bugs at lists.llvm.org
This: https://godbolt.org/g/b2t1a9
unsigned long f(unsigned long x, int amt)
{
x += (x << amt) | (x >> (64 - amt));
return x & 0xffffffffu;
}
unsigned long g(unsigned long x, int amt)
{
x += (x << amt) | (x >> (64 - amt));
return x;
}
produces:
f(unsigned long, int): # @f(unsigned long, int)
mov rax, rdi
mov ecx, esi
shl rax, cl
mov ecx, 64
sub ecx, esi
mov rdx, rdi
shr rdx, cl
or edx, eax
add edi, edx
mov rax, rdi
ret
g(unsigned long, int): # @g(unsigned long, int)
mov rax, rdi
mov ecx, esi
rol rax, cl
lea rax, [rax + rdi]
ret
Found while investigating a significant perf difference between LLVM and gcc on
a hash function. (Yes, "amt" is variable in the code in question.)
--
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/20171201/3d38130f/attachment.html>
More information about the llvm-bugs
mailing list