[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug tree-optimization/94893] New: Sign function not getting optimized to simple compare
From: "gabravier at gmail dot com" <gcc-bugzilla () gcc ! gnu ! org>
Date: 2020-04-30 17:31:16
Message-ID: bug-94893-4 () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94893
Bug ID: 94893
Summary: Sign function not getting optimized to simple compare
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
inline int sign(int x)
{
return (x >> 31) | ((unsigned)-x >> 31);
}
bool f(int x)
{
return sign(x) < 1;
}
With -O3, LLVM outputs :
f(int):
test edi, edi
setle al
ret
GCC outputs :
f(int):
mov eax, edi
sar edi, 31
neg eax
shr eax, 31
or eax, edi
setle al
ret=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic