This is the mail archive of the gcc@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]

Re: Gcc extra alignment..




On Tue, 31 Oct 2000, Loren James Rittle wrote:
> 
> bar ();
> 
> foo ()
> {
>   do { bar (); } while (0);
> }
> 
> [ deleted ]
> 
> Looks like the padding is still there.

Not just that. When you enable optimizations, the padding goes away, but
it looks like

	foo:
	        subl    $12, %esp
	        call    bar
	        addl    $12, %esp
	        ret

even at -O3 -fomit-frame-pointer.

Now, remove the "do { } while (0)", and the end result is the much more
reasonable (even pretty):

	foo:
	        jmp     bar

So obviously padding isn't the only thing that "do { } while (0)" will do
for you..

(I wonder why. It's not as if we're adding any new variables in scope or
anything like that. Strange. I'm sure it has a perfectly good explanation,
but it does look like some obvious optimization is trivially missed).

		Linus


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