r194403 - Using an invalid -O falls back on -O3 instead of an error

Hal Finkel hfinkel at anl.gov
Mon Nov 11 12:31:02 PST 2013


----- Original Message -----
> 
> 
> 
> 
> 
> On Mon, Nov 11, 2013 at 11:54 AM, Arthur O'Dwyer <
> arthur.j.odwyer at gmail.com > wrote:
> 
> 
> 
> > My preference would be to have '-O' be the fallback, and that in
> > turn be
> > equivalent to '-O2' which is often viewed as a reasonable default
> > level of
> > optimization.
> 
> Note that the commit message is no longer 100% non-misleading. The
> message actually given by the code is "optimization level '-O20' is
> unsupported; using '-O3' instead."
> 
> The English semantics aren't "oh no, we don't know the user's intent,
> let's do something sensible instead." The English semantics are more
> like "aha, the user explicitly requested CRAZY HIGH levels of
> optimization; let's give him the highest level we currently support."
> 
> Existing projects use things like -O99 for this purpose.
> 
> You would probably agree that it doesn't make sense to have -O4
> perform fewer optimizations than -O3, right? That's what would happen
> if you made -O4 (-O5, -O99) equivalent to -O2. (Also what Hal said.
> :))
> Actually, no, I disagree with your conclusions.
> 
> 
> I think the far and away most likely reason for a number greater than
> 3 is using a numbering system from a compiler other than GCC.

In my experience, this is not at all true. It came from relatively-inexperienced users who kept increasing the n in -O<n> while their code kept getting faster. Due to random variance, sometimes the higher number seemed a little faster than -O3, and so they kept it.

> I have
> no idea what 4 or 5 map to for those. Maybe they map to something
> like -O3, maybe not.
> 
> 
> I think assuming that these optimizations are ordered in some way
> based on "fast" is wrong. For *many* C++ codebases -O2 produces
> consistently higher quality code than -O3.

What does *many* mean? Even a small percentage of the total can be a lot in absolute magnitude. -O3 should produce faster code than -O2, on average, and if that is not true, then we have a serious problem (and the test suite should do more -O2 testing).

Also, this might depend on the platform. Embedded cores might benefit much more from -O3 than fancy out-of-order desktop chips.

Can you please explain further?

 -Hal

> 
> 
> If we're going to *do* something when we do not understand the
> specific nature of the user's request, I would like us to do the
> most generic thing with the fewest assumptions. All we know is that
> the user wanted *some* optimization, not how much. Let's pick our
> default for "some" optimization.
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the cfe-commits mailing list