GNU Coding Standards -- updated
Joe Buck
jbuck@synopsys.COM
Wed Aug 15 15:22:00 GMT 2001
>
> 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.
More information about the Gcc
mailing list