strange x86 generation of 2.95 compare to 1.1.2

I Lee Hetherington ilh@sls.lcs.mit.edu
Thu Jun 17 14:16:00 GMT 1999


The following code produces a lot of extra stack manipulations with
gcc-2.95 (19990608) compared to egcs-1.1.2 and gcc-2.7.2.3:

        void bar(int x);
        void foo(int x)
        {
                if (x == 1)
                        return;
                bar(x);
        }

gcc-2.95 with -O2 -fomit-frame-pointer produces:

        foo:
                subl $12,%esp
                movl 16(%esp),%eax
                cmpl $1,%eax
                je .L2
                addl $-12,%esp
                pushl %eax
                call bar
                addl $16,%esp
        .L2:
                addl $12,%esp
                ret

What is with all the manipulation of %esp?!?  In contrast, gcc-2.7.2.3
and egcs-1.1.2 produce exactly what I would expect:

        foo:
                movl 4(%esp),%eax
                cmpl $1,%eax
                je .L1
                pushl %eax
                call bar
                addl $4,%esp
        .L1:
                ret

This seems like a step backwards.

--Lee Hetherington


More information about the Gcc mailing list