Discrepency between compiler and docs for optimzation flags

Andy Falanga (afalanga) afalanga@micron.com
Tue Jun 10 03:10:00 GMT 2014


Hello,

I'm trying to understand something that appears to me that it shouldn't be happening.  For the project I'm working on, I'm one of 6 developers, we were using optimization option -Os.  For reasons beyond the scope of this question, we've switched from this to -O2.  On my CentOS 6.5, 64 bit, system, I'm using gcc 4.4.7.  On the CentOS 6.0 - 6.2, 32 bit systems we build for, we're using gcc 4.4.4.  I could find docs for 4.4.7 online (https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/).

From these docs, I found the following: 
-Os disables the following optimization flags:

          -falign-functions  -falign-jumps  -falign-loops 
          -falign-labels  -freorder-blocks  -freorder-blocks-and-partition 
          -fprefetch-loop-arrays  -ftree-vect-loop-version
     
Today, while doing some further research into optimization options, and investigating the -march= option, I found a gem of an option which I didn't know existed before: --help=.  After a little bit of experimentation I did the following:

$ gcc -Q -O2 --help=optimizers > O2settings
$ gcc -Q -Os --help=optimizers > Ossettings

I then diff'd them: gvimdiff O2settings Ossettings.  What I wasn't expecting is that the only difference between the two files is:

O2settings:
  -finline-functions          		[disabled]

Ossettings:
  -finline-functions          		[enabled]


Since I'm new to these options, am I doing it incorrectly?  Is this compiler implementation broken?  Is this normal for RHEL (from which CentOS is derived)?  Any help in understanding this would be good.

Just for the record the following options, which the docs say should be different but aren't:

align-functions:  		enabled
align-jumps:			enabled
align-labels:			enabled
align-loops:			disabled
reorder-blocks:			enabled
reorder-blocks-and-patition:	disabled
prefetch-loop-arrays:		disabled
tree-vect-loop-version:		enabled

Andy



More information about the Gcc-help mailing list