Re: Regarding -fno optimization options
|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
Hi,I tried in the last days to reconstruct an optimization level by just using the individual optimization flags. Well, it did not work at all.
My basic idea was to take the list from "-Q -v" and use it. But there still were some differences where comparing the list from a basic optimization level with the list from the flags.
Also, as I am working with a processor simulator (gem5), I was able to compare the performance of both programs. There was a big difference between using e.g. O3 and setting the flags.
Also I found this FAQ entry: http://gcc.gnu.org/wiki/FAQ#optimization-options Ian, is this still valid? Cheers, Ralf Am 01.08.2012 22:25, schrieb Parang Saraf:
Hi, I have been digging further into this. I can see the flags enabled for each optimization level using "gcc -Q -On -help=optimizers" (flags enabled) Also, when I compile a program for a particular optimization level, I can see the flags used by gcc using, "gcc -Q -v -On program.c" (flags used). I am working with gcc 4.4.5. I found a few anomalies, which are mentioned below: 1. There are a few flags which are documented in O1 but are enabled for O0. Example: -funit-at-a-time. This flag is both enabled and used at O0 2. There are a few flags, which are documented in O1 and are not enabled for O0 (which is correct), but are still used for O0. Example: -fauto-inc-dec flag is documented in O1 and is not enabled for O0 but is still used by O0. 3. Flags which are enabled but are not used. Example: flags -fdce and -fdse are enabled for O0, O1 but is never used by the compiler. 4. Here is the complete list of flags distribution: O0: documented 0; enabled 35; used 43 O1: documented 26; enabled 56; used 66 O2: documented 55; enabled 80; used 91 O3: documented 61; enabled 86; used 97 I understand that there are a few flags which are used internally by the gcc. But my question is, if some of the flags are shown as enabled for a particular optimization level, why are they are not used during compilation? Also, ideally if I am using -O0, i should not be able to add/enable optimization flags. But when i enable some of the O1 optimization flags at O0, I could see gcc using them. For example: "gcc -Q -v -O0 -ftree-fre program.c". Here -ftree-fre is an optimization flag from O1, but still it gets enabled at -O0. Most importantly: How can I make my gcc 4.5.4 adhere strictly with the 4.5.4 documentation? If I have to recompile gcc and make some changes to the config files, then please let me know. I will greatly appreciate your response in this regard. Regards Parang On Wed, Jul 25, 2012 at 11:24 AM, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: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.
-- Dr. Ralf Jahr Universität Augsburg Lehrstuhl für Systemnahe Informatik und Kommunikationssysteme Institut für Informatik Universitätsstraße 6a 86159 Augsburg Telefon: +49 (821) 598-2354 E-Mail: ralf.jahr@xxxxxxxxxxxxxxxxxxxxxxxxxx