https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61588
Bug ID: 61588 Summary: Optimization defaults are not what documentation say they should be Product: gcc Version: 4.4.7 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: af300wsm at gmail dot com Created attachment 32988 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32988&action=edit Os settings for gcc 4.4.7 The default settings for optimization levels O2 and Os are not what the documentation say they should be. This is true for gcc 4.4.7 on CentOS 6.5 (it is also true for gcc 4.4.4 on CentOS 6.0). The documentation found here: https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Optimize-Options.html#Optimize-Options shows what is turned on/off between O2 and Os optimization options. Specifically, the documentation implies that Os is O2 but favoring size of the binary over speed. The following are the noted exceptions between Os (off) and O2 (on): - falign-functions - falign-jumps - falign-loops - falign-labels - freorder-blocks - freorder-blocks-and-partition - fprefetch-loop-arrays - ftree-vect-loop-version There are attachments to this bug for the O2 and Os settings for 4.4.4 (CentOS 6.0) and 4.4.7 (CentOS 6.5). As you'll notice with diffing between OS versions, the list is identical (except that in CentOS 6.5, gcc 4.4.7, fstrict-enums exists), and diffing between gcc versions shows only 1 difference: finline-functions. Contrary to the gcc documentation for 4.4.7, all values noted above are enabled except falign-loops, freorder-blocks-and-partition and fprefetch-loop-arrays. Most concerning, however, is that all listed optimization settings between O2 and Os are identical with one exception. The one difference between these two is finline-functions. Oddly, this is *disabled* in O2 and *enabled* in Os. This seems contrary to the stated goal of Os. The attached files were generated with this command: $ gcc -Q -Ox --help=optimizers > <output_file> # where x is either 2 or s This link, https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Overall-Options.html#Overall-Options , shows the use of the -c option as well. However, I noted this made no difference to the output.