This is the mail archive of the gcc-patches@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]

Re: -Os should default optimize to 2, without enforcing it



I'm confused.

Isn't -Os supposed to modify -O1, -O2 so that the same -fxxx optimization
techniques are used, except code size is favored instead of speed?
At least, this is how I understood.

Here are some quotes from toplev.c:


/* Nonzero means optimize for size.  -Os.
   The only valid values are zero and non-zero. When optimize_size is
   non-zero, optimize defaults to 2, but certain individual code
   bloating optimizations are disabled.  */

int optimize_size = 0;


But, according to the code in main(), the following happens:


gcc -O1      =>  use O1, optimize for speed
gcc -Os -O1  =>  use O1, optimize for size
gcc -Os      =>  use O2, optimize for size (-O2 is defaulted by -Os)
gcc -O1 -Os  =>  use O2, optimize for size (identical to above)
...
gcc -O3      =>  use O3, optimize for speed
gcc -Os -O3  =>  use O3, optimize for size
gcc -O3 -Os  =>  use O2, optimize for size

... confusing, isn't it?

As opposed to my understanding (that -Os is used in conjunction with
-O<number>), you are saying that -Os is a standalone option, as the
others, and -Os should not be combined with other -O<number>.
But, in this case, why "gcc -Os -O1" does not have the effect of
"gcc -O1"?
If this is the case, then the code still needs to be fixed.

I agree that there is no much point for using -O3 in conjunction with -Os,
but, on the other hand, it makes sense to use "-O1 -Os" (which should be
identical to "-Os -O1"), and also "-O2 -Os" (which should be identical to
"-Os -O2").

After it will be established what behavior will -Os have (I still feel
a fix is needed, either if I or you are right), I will implement a similar
behavior to the previously proposed option -Ox.


Cosmin


On Fri, 9 Mar 2001, Geoff Keating wrote:

> Cosmin Truta <cosmin@cs.toronto.edu> writes:
> 
> > Hi again,
> > 
> > I noticed an inconsistency between the comment of optimize_size (that
> > *defaults* optimize to 2 -- I guess this is the initial intention) and the
> > initialization (that *enforces* optimize to be 2). The patch below,
> > independent of the patch sent in my previous message, fixes the problem:
> 
> No, it's supposed to be that way.  The flag is
> 
> -O[setting]
> 
> where 'setting' can be `0', `1', `2', `3', or `s', and the default is
> `1' if none is specified.
> 
> -- 
> - Geoffrey Keating <geoffk@geoffk.org>
> 



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