From: Andi Kleen <ak@muc.de>
Subject: Re: ADA on the super
Date: 1998/04/21
Date: 1998-04-21T00:00:00+00:00 [thread overview]
Message-ID: <m3son7o2zz.fsf@fred.muc.de> (raw)
In-Reply-To: dewar.893122141@merv
dewar@merv.cs.nyu.edu (Robert Dewar) writes:
> <<Gnat has good optimization. Gnat has good code generation
> except for packed arrays. Robert is right about bench
> marking your application with ALL of your data before
> deciding what is fast and what is slow.
> >>
>
> Actually, this is probably an over-generalization. Packed array stuff is
> notorious, since there are so many special cases, and a given compiler
> is likely to do some but not all special casing. GNAT does some packed
> array stuff really efficiently, and other stuff is pretty horrible. A
> good challenge is Mats Weber's
>
> x := x(1 .. 31) & x(0);
>
> to do a simple rotate. It would be impressive if a compiler generated
> a single rotate instruction for this -- well to be more accurate, it
> would be surprising if such an optimization came out of a general
> approach (it is always easy to add one more special case). Certainly
> GNAT comes *nowhere* near generating a single instruction for this
> particular case.
It is surprising that Gnat doesn't do this. At least the C frontend of gcc
does a very similar optimization:
/* Expects sizeof(unsigned int) == 4 */
int rotate(unsigned int i)
{
return (i << 1) | (i >> 31);
}
Compiled with -O2 on i386 Linux.
.file "t13.c"
.version "01.01"
gcc2_compiled.:
.text
.align 4
.globl rotate
.type rotate,@function
rotate:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
roll $1,%eax
leave
ret
.Lfe1:
.size rotate,.Lfe1-rotate
.ident "GCC: (GNU) 2.7.2.1"
-Andi
next prev parent reply other threads:[~1998-04-21 0:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-17 0:00 ADA on the super Alex Stuebinger
1998-04-18 0:00 ` Robert Dewar
1998-04-18 0:00 ` stuebi
1998-04-19 0:00 ` Greg Lindahl
1998-04-19 0:00 ` Robert Dewar
1998-04-20 0:00 ` Michael F Brenner
1998-04-20 0:00 ` Toon Moene
1998-04-21 0:00 ` Larry Kilgallen
1998-04-21 0:00 ` Toon Moene
1998-04-20 0:00 ` Robert Dewar
1998-04-21 0:00 ` Andi Kleen [this message]
1998-04-21 0:00 ` Robert Dewar
1998-04-21 0:00 ` Ada on the super (packed arrays) Michael F Brenner
1998-04-22 0:00 ` Andi Kleen
1998-04-21 0:00 ` ADA on the super Larry Kilgallen
1998-04-20 0:00 ` K. Mathias
1998-04-20 0:00 ` Acronyms was: " Eugene Miya
[not found] <6hibr7$kf5$1@bambi.zdv.Uni-Mainz.DE>
1998-04-21 0:00 ` Ada " Richard Toy
1998-04-21 0:00 ` Juergen Pfeifer
1998-04-22 0:00 ` Alex Stuebinger
1998-04-22 0:00 ` Jerry van Dijk
1998-04-22 0:00 ` John M. Mills
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox