On 25 July 2012 07:34, Parang Saraf wrote: > Hi, > > I have few very basic questions: > > 1. I want to turn-on only some of the optimization flags for O1. Is > doing this enough?: > > " gcc -O0 -fcprop-registers -fdefer-pop -fif-conversion [...] -o > program program.c " > > I tried with a bunch of options, generated an assembly file and > compared the assembly file with the assembly generated from just -O0. > Ideally, there should be a difference. Right? With -O0 there is no optimisation done, you can't enable individual optimisation passes if no optmisation is done. You probably want to use -O1 and selectively turn off the passes you don't want. > 2. Secondly, if I can switch-on flags like this, then what is the need > for -fno optimization options? Are -fno options meant just to reduce > the number of command line options, ie. say if for O1 I want most of > the flags except a few, then I can do "-O1 -fno-flag" ? Yes. It's easier to say "I want -O2 without X" rather than "I want -O1 with A and B and C and D and ..." > If that's the > case, then why not all the flags have a -fno switch. It is the case, and I think they do all have -fno switches. > 3. In the gcc 4.7.1 optimization options documentation, there is a line: > > " 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. " > > What exactly is the meaning of second line? What I said above. Without -O1 or higher most optimisations will not run, even if you say -fxxx.