Suboptimal code on x86

Martin Kahlert martin.kahlert@mchp.siemens.de
Tue Jul 7 05:29:00 GMT 1998


Quoting Remi Guyomarch (rguyom@mail.dotcom.fr):
> This is with snapshot 19980530 :
> 
> void foo (int) __attribute__ ((__regparm__(1)));
> 
> void foo (int bar) {
>     int baz = bar*2;    
>     printf ("%d %d", bar, baz);
> }
> 
> with -O9 -fomit-frame-pointer give me this code :
> 
> foo:
>         movl %eax,%edx	##
>         movl %edx,%eax	## huh ?
>         addl %edx,%eax
>         pushl %eax
>         pushl %edx
>         pushl $.LC0
>         call printf
>         addl $12,%esp
>         ret

With this newer one (gcc -v):
Reading specs from /sw/egcs/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.91.42/specs
gcc version egcs-2.91.42 19980621 (gcc2 ss-980502 experimental)

I get:
foo:
     movl %eax,%edx
     addl %eax,%edx
     pushl %edx
     pushl %eax
     pushl $.LC0
     call printf
     addl $12,%esp
     ret

So it seems to be corrected, yet.
Martin.


-- 
What is the difference between Jurassic Park and Microsoft?
One is an over-rated high tech theme park based on prehistoric 
information and populated mostly by dinosaurs, 
the other is a Steven Spielberg movie.



More information about the Gcc mailing list