This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is -O9 legitimate?


Lee Rhodes wrote:

> I could not find any reference to either -O9 or -fno-strict-aliasing in the
> 4.2.0 gcc.pdf manual.  I did find -fstrict-aliasing, but most commands that
> have a -fno- option are listed in the manual.

The fact is that no- can be added to nearly every -W and -f option.  But
this means there are two versions of every flag, and if every single one
was listed the documentation would become very cumbersome listing every
option twice.  This is explained explitcitly:

<http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html>

> Options of the form -fflag specify machine-independent flags. Most flags 
> have both positive and negative forms; the negative form of -ffoo would 
> be -fno-foo. In the table below, only one of the forms is listed?the one 
> you typically will use. You can figure out the other form by either 
> removing `no-' or adding it.

<http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>

> Each of these specific warning options also has a negative form 
> beginning `-Wno-' to turn off warnings; for example, -Wno-implicit. This 
> manual lists only one of the two forms, whichever is not the default.

> What effect does -O9 have?

It has the same effect as -O3.  The -O flag will accept any number from
0-9 but only zero through three are implemented, and I don't think that
anyone has any plans to ever implement four through nine any time soon. 
The fact that people use this -O9 idiom is a little disturbing, because
it implies that they want every conceivable optimization that gcc could
possibly ever offer, even if it made compilation take weeks for no
gain.  But by design dangerous or futile optimizations do not get
enabled with -O levels because these -O options are meant to represent
blends of settings that are generally considered safe and useful by a
large range of users by the compiler authors.  So specifying -O9 is a
bit of "but this one goes to eleven!"-type nonsense, if you ask me.  Or
perhaps it's just blind emulation of commands like gzip that also accept
a -0 through -9, but in that case -9 will actually do more than the
lower numbers.

> Would -fno-strict-aliasing turn off strict-aliasing?

Yes.

> Is there a gcc switch that would issue warnings about either obsolete or
> ignored command line switches?

gcc will warn about options that have no effect and options that are
slated for removal in the next revision.  However, this doesn't apply to
either of the above, as -fno-strict-aliasing is documented and
supported, and -O9 is certainly not ignored nor obsolete.  Whether -O9
is legitimate is debatable as I don't see anywhere in the manual where
it says that any digit can be used, but it is an established notion that
you can do this (perhaps as other compilers have a similar option) so I
doubt it's ever going to change.  Still, the idea that specifying
anything above three has any effect is wrong, as is the notion that it
likely ever will, so I would certainly recommend doing your part to
eliminate this idiom from common usage.

Brian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]