Question about default optimizations

Jonathan Wakely
Mon Nov 23 12:35:00 GMT 2015

On 21 November 2015 at 21:32, staticx wrote:
> Hi all,
> I am implementing a generator of optimization sequences for GCC 4.8.4. The
> Generator use an evolutionary algorithm to evolve a list of optimization
> sequences like acovea (
> The list of optimizations I have to chosen to evolve are the flags that can
> be turned on or off in each of the standard GCC levels 01 to O3 and Ofast
> (around 78 flags).
> I ve read that "most optimizations are only enabled if an -O level is set on
> the
> command line. Otherwise they are disabled, even if individual optimization
> flags are specified"
> So if I have a list of generated sequences, How can I add default
> optimizations?

What do you mean by default optimizations?

> O1 + <generated_sequence_1> == O2 + <generated_sequence_1> == O3 +
> <generated_sequence_1> ???

That doesn't make any sense, did you mean to say generated_sequence_2
and generated_sequence_3, instead of the same one three times?

> If not, how can I tell GCC to run default optimizations in addition to my
> generated flags.

I don't think I understand what you're asking, but maybe the answer is
"use one of the -On options".

The optimisation flags have negative forms as well as positive (but
you know that, because you've read the docs carefully now, right?) So
you can say "-O1 -ffoo -fbar" or you can say "-O2 -fno-foo -fno-bar".
So by using -O2 you would enable any optimizations that are part of
-O2 but don't have their own -f flag (I don't know if such
optimizations exist, I'm just speculating based on which says
"Not all optimizations are controlled directly by a flag. Only
optimizations that have a flag are listed in this section.")

> NB:
> In acovea, they said "Each initial population is a set of randomly-selected
> acovea_organisms. I also "seed" each population with predefined organisms
> that represent the "composite" optimization options -O1, -O2, -O3, and -Os.
> That way, I ensure that the default settings get a chance to compete with
> random option sets"
> How did they define  the "composite" optimization options ?

Why are you asking that here? Acovea was a separate project, you
should ask the people who worked on it, or read their documentation
and/or code.

More information about the Gcc-help mailing list