This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: middle-end/10415: allocated stack space non optimimal
- From: Wolfgang Bangerth <bangerth at ices dot utexas dot edu>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 15 Apr 2003 22:36:00 -0000
- Subject: Re: middle-end/10415: allocated stack space non optimimal
- Reply-to: Wolfgang Bangerth <bangerth at ices dot utexas dot edu>
The following reply was made to PR middle-end/10415; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth at ices dot utexas dot edu>
To: gcc-gnats at gcc dot gnu dot org
Cc:
Subject: Re: middle-end/10415: allocated stack space non optimimal
Date: Tue, 15 Apr 2003 17:35:03 -0500 (CDT)
---------- Forwarded message ----------
Date: Tue, 15 Apr 2003 22:42:42 +0200
From: GrzegorzB <b dot grzes at interia dot pl>
To: Wolfgang Bangerth <bangerth at ices dot utexas dot edu>
Subject: Re: middle-end/10415: allocated stack space non optimimal
Wolfgang Bangerth wrote:
>>Program test.c:
>>
>>void f() {
>> char buf[3];
>>}
>>
>>main() {
>> f();
>>}
>>
>>I compile this:
>>gcc -S -o test test.c
>
>
> What happens if you switch on optimization? Is stack allocation better
> then?
>
> [I think that the compiler will just optimize away everything in that
> case, but you might prevent this by doing something like
>
> void p(char *x);
> void f() {
> char buf[3];
> p(buf);
> }
>
> and simply not defining f().]
>
> W.
>
If I compile test.c with option -O0, I have (for "char buf[3]"):
pushl %ebp
movl %esp, %ebp
subl $24, %esp
leave
for option -O3 is:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
leave
If is "char buff[4]" and -O3 is:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
leave
and for -O0 option (and "char buf[4]"):
pushl %ebp
movl %esp, %ebp
subl $4, %esp
leave
So sorry, I thought it is a bug.
----------------------------------------------------------------------
KLIKNIJ 2 razy TAK >>> http://link.interia.pl/f170d