public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Is -O9 legitimate?
@ 2007-07-09 18:26 Lee Rhodes
  2007-07-09 22:44 ` Brian Dessent
  0 siblings, 1 reply; 3+ messages in thread
From: Lee Rhodes @ 2007-07-09 18:26 UTC (permalink / raw)
  To: gcc-help

I am studying a Makefile where the author specified the execution of GCC as
follows:

  gcc -O9 -fno-strict-aliasing  ...

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.

What effect does -O9 have?

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

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

Are there other undocumented switches?

Lee.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is -O9 legitimate?
  2007-07-09 18:26 Is -O9 legitimate? Lee Rhodes
@ 2007-07-09 22:44 ` Brian Dessent
  2007-07-10 13:19   ` Segher Boessenkool
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Dessent @ 2007-07-09 22:44 UTC (permalink / raw)
  To: Lee Rhodes; +Cc: gcc-help

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is -O9 legitimate?
  2007-07-09 22:44 ` Brian Dessent
@ 2007-07-10 13:19   ` Segher Boessenkool
  0 siblings, 0 replies; 3+ messages in thread
From: Segher Boessenkool @ 2007-07-10 13:19 UTC (permalink / raw)
  To: gcc-help; +Cc: Lee Rhodes

>> 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.

-O42 works, too; not just numbers smaller than 10.

> 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.

Also if a future -O9 wouldn't work for them (perhaps it
would break the C standard in a minor but significant
way); also it wouldn't enable _all_ optimisations, since
not all optimisation passes are a win on all code and so
some wouldn't be enabled by default at any -O level.

> 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.

Well it's _cool_, eh?  :-)


Segher

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-10 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-09 18:26 Is -O9 legitimate? Lee Rhodes
2007-07-09 22:44 ` Brian Dessent
2007-07-10 13:19   ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).