From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2235 invoked by alias); 15 Apr 2003 22:36:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 2218 invoked by uid 71); 15 Apr 2003 22:36:00 -0000 Date: Tue, 15 Apr 2003 22:36:00 -0000 Message-ID: <20030415223600.2217.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Wolfgang Bangerth Subject: Re: middle-end/10415: allocated stack space non optimimal Reply-To: Wolfgang Bangerth X-SW-Source: 2003-04/txt/msg00722.txt.bz2 List-Id: The following reply was made to PR middle-end/10415; it has been noted by GNATS. From: Wolfgang Bangerth To: gcc-gnats@gcc.gnu.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 To: Wolfgang Bangerth 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