[llvm-bugs] [Bug 45759] New: Failure to elide useless mov in sign function
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Apr 30 10:41:10 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45759
Bug ID: 45759
Summary: Failure to elide useless mov in sign function
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: gabravier at gmail.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
int sign(int x)
{
return -((unsigned)x >> 31) | ((unsigned)-x >> 31);
}
With -O3, GCC outputs this :
sign(int):
mov eax, edi
sar edi, 31
neg eax
shr eax, 31
or eax, edi
ret
LLVM outputs this :
sign(int):
mov eax, edi
mov ecx, edi
sar ecx, 31
neg eax
shr eax, 31
or eax, ecx
ret
Most likely this is specific to the X86 backend and its register allocator, so
I marked it as such
--
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/20200430/0c566c53/attachment.html>
More information about the llvm-bugs
mailing list