This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GNU Coding Standards -- updated
- To: carlo at alinoe dot com (Carlo Wood)
- Subject: Re: GNU Coding Standards -- updated
- From: Joe Buck <jbuck at synopsys dot COM>
- Date: Wed, 15 Aug 2001 18:33:25 -0700 (PDT)
- Cc: pfeifer at dbai dot tuwien dot ac dot at (Gerald Pfeifer), gcc at gcc dot gnu dot org, mark at codesourcery dot com (Mark Mitchell)
>
> On Wed, Aug 15, 2001 at 02:12:05PM +0200, Gerald Pfeifer wrote:
> > Please note that as of today the GNU Coding Standards have been enhanced
> > by a new section that was originally suggested by Mark for inclusion in
> > the GCC coding standards and edited and submitted for inclusion in the GNU
> > Coding Standards by me:
> >
> > Conditional Compilation
> > http://www.gnu.org/prep/standards.html#SEC11
>
> Will this extra 'if' also be removed from the end-result
> (the executable) if one compiles with -O0 ?
I just tried it for the following code:
---------------------
#define FLAG 0
int a(int);
int b(int);
int foo(int bar)
{
if (FLAG)
return a(bar);
else
return b(bar);
}
---------------------
I tried
gcc -O0 -S foo.c
On Solaris, for gcc 2.95.2, code from both branches appears, but the
branch is unconditional (no if-test). That is, the call to a appears
in the assembly language code but it is unreachable.
For gcc 3.0, only the call to b is generated; there is no branch.
So, for 2.95.2 there is space overhead but (almost) no time overhead
modulo cache effects; for 3.0 there is neither space nor time overhead.