[Bug c/15823] New: optimise >>> style calculation
ajrobb at bigfoot dot com
gcc-bugzilla@gcc.gnu.org
Fri Jun 4 16:41:00 GMT 2004
The C code fragment (i & (~0<<n))/(1<<n) is equivalent to Java's i>>>n
arithmetic shift (at least for n < sizeof(i)*CHAR_BIT).
There are two problems:
1) if n is not a manifest constant, i/(1<<n) uses divide.
2) Even when n is a constant, say 2:
(i & ~3)/4
still does not compile to a single SAR (x86) it still checks the sign and adds
3 if negative.
--
Summary: optimise >>> style calculation
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ajrobb at bigfoot dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i586-suse-linux
GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15823
More information about the Gcc-bugs
mailing list