public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/15823] New: optimise >>> style calculation
@ 2004-06-04 16:41 ajrobb at bigfoot dot com
  2004-06-04 16:48 ` [Bug c/15823] " pinskia at gcc dot gnu dot org
  2004-06-24  8:48 ` ajrobb at bigfoot dot com
  0 siblings, 2 replies; 3+ messages in thread
From: ajrobb at bigfoot dot com @ 2004-06-04 16:41 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-06-24  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-04 16:41 [Bug c/15823] New: optimise >>> style calculation ajrobb at bigfoot dot com
2004-06-04 16:48 ` [Bug c/15823] " pinskia at gcc dot gnu dot org
2004-06-24  8:48 ` ajrobb at bigfoot dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).