This is the mail archive of the 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]
Other format: [Raw text]

Weird optimization flags behavior


I am facing some weird issues with the optimization flags. I tried
posting this in the gcc-help but got no response. Here is my query:

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
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

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.


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