This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

stack manipulations in gcc-2.95.2


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!

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.

How much is the code bloat due to this?

In a file of 5776 instructions, fully 896 instructions were stack manipulations.
This means almost 2700 bytes were used for stack manipulations from a total
code size of 19872 bytes. Approx 10% of the code size!

I suppose that the objective of gcc here is to keep a cache aligned stack. 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. The 2700 bytes
can't be completely avoided of course, but very simple optimizations allow to
reduce the code size. Lcc-win32 reduces this (when compiling the same file)
to 251 instructions only, i.e. 753 bytes. 

Are there any measurements that would prove if this stack manipulations are
at all justified?

Thanks for your time

-- 
Jacob Navia	Logiciels/Informatique
41 rue Maurice Ravel			Tel 01 48.23.51.44
93430 Villetaneuse 			Fax 01 48.23.95.39
France

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]