stack manipulations in gcc-2.95.2

Jeffrey A Law law@cygnus.com
Tue Jan 11 23:05:00 GMT 2000


  In message < m1284xO-000Y2gC@jacob.remcomp.fr >you write:
  > Hi
  > 
  > I have noticed that very often gcc generates code like:
  > 	addl 	$-8,%esp
  > 	pushl	arg1
  > 	pushl	arg2
  > 	call	something
  > 	...
  > 	addl	32,%esp
  > instead of the sequence used in most compilers:
  > 	pushl	arg1
  > 	pushl	arg2
  > 	call	something
  > 	addl	$8,%esp
  > that is 3 bytes shorter!
Generally the compiler does.  However, there are some circumstances where
it can't (due to phase ordering issues).


  > To make things worst, there are often sequences like:
  >         addl $32,%esp
  >         addl $-4,%esp
  >         addl $-8,%esp
  > instead of combining this into
  > 	addl $20,%esp
  > saving 6 bytes.
I'd like to see sample code for this one.  Again, due to phase ordering
issues it is possible to get a pair of stack pointer adjustments back
to back, but they're rare.


  > This is not a bad idea, but I am very skeptical if the code bloat that
  > this produces doesn't largely offset any possible gains for cache
  >  alignment.
Getting stack alignment right can mean a factor of 2 or more for FP intensive
code on modern ia32 machines as measured by standard benchmarks like Spec.

jeff




More information about the Gcc-bugs mailing list