This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/15823] New: optimise >>> style calculation
- From: "ajrobb at bigfoot dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Jun 2004 16:41:13 -0000
- Subject: [Bug c/15823] New: optimise >>> style calculation
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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