Discussion:
Why are the optimization settings not what the docs say they should be
Andy Falanga (afalanga)
2014-06-20 16:22:43 UTC
Permalink
Hello,

I'd like to understand why the optimization settings for -O2 and -Os aren't what the docs say they should be. I ran these two commands:

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

and then diff'd the files. Since I'm using gcc 4.4.7 on CentOS 6.5, I'm referencing these docs: https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Optimize-Options.html#Optimize-Options. These docs say that -Os and -O2 are identical with the following exceptions:

- falign-functions
- falign-jumps
- falign-loops
- falign-labels
- freorder-blocks
- freorder-blocks-and-partition
- fprefetch-loop-arrays
- ftree-vect-loop-version

The docs tell me that these are disabled in -Os from -O2. However, if I've used the gcc command correctly, this tells a much different story. In each case, the value for -Os and -O2 are identical. All are enabled except for falign-loops, freorder-blocks-and-partition and fprefetch-loop-arrays. Most importantly, however, they are all the same for either optimization level.

In fact, the only difference between the two is finline-functions: which is *off* in -O2 and *on* in -Os. That seems incorrect. Since -Os is concerned with size, wouldn't that option want to be disabled, not enabled, for size conscious optimization?

If this is something that the GCC team isn't responsible for, because, perhaps, GCC was built by the CentOS people, that's fine. I'll take up the question with them. I'd like to know if I've just misunderstood the command issued to look at optimization settings (I've made those mistakes before).

Thanks,
Andy
Manuel López-Ibáñez
2014-06-21 15:57:09 UTC
Permalink
Post by Andy Falanga (afalanga)
Hello,
$ gcc -Q -O2 --help=optimizers > O2settings
$ gcc -Q -Os --help=optimizers > Ossettings
- falign-functions
- falign-jumps
- falign-loops
- falign-labels
- freorder-blocks
- freorder-blocks-and-partition
- fprefetch-loop-arrays
- ftree-vect-loop-version
The docs tell me that these are disabled in -Os from -O2. However, if I've used the gcc command correctly, this tells a much different story. In each case, the value for -Os and -O2 are identical. All are enabled except for falign-loops, freorder-blocks-and-partition and fprefetch-loop-arrays. Most importantly, however, they are all the same for either optimization level.
In fact, the only difference between the two is finline-functions: which is *off* in -O2 and *on* in -Os. That seems incorrect. Since -Os is concerned with size, wouldn't that option want to be disabled, not enabled, for size conscious optimization?
If this is something that the GCC team isn't responsible for, because, perhaps, GCC was built by the CentOS people, that's fine. I'll take up the question with them. I'd like to know if I've just misunderstood the command issued to look at optimization settings (I've made those mistakes before).
I think this is a bug in GCC but not sure where.
It is possible that the output returned by --help is not correct, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60481
It is also possible that the documentation is outdated.

The only way to be sure is to look at the source code and see what is
actually being enabled/disabled. I would suggest to open a bug report
and add there as much info as you can find.

Cheers,

Manuel.
Andy Falanga (afalanga)
2014-06-23 15:01:51 UTC
Permalink
-----Original Message-----
I think this is a bug in GCC but not sure where.
It is possible that the output returned by --help is not correct, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60481
It is also possible that the documentation is outdated.
The only way to be sure is to look at the source code and see what is
actually being enabled/disabled. I would suggest to open a bug report
and add there as much info as you can find.
Cheers,
Manuel.
Thank you Manuel. I will do this today (I hope).

Andy
Andy Falanga (afalanga)
2014-06-23 17:25:08 UTC
Permalink
Post by Manuel López-Ibáñez
I think this is a bug in GCC but not sure where.
It is possible that the output returned by --help is not correct, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60481
It is also possible that the documentation is outdated.
The only way to be sure is to look at the source code and see what is
actually being enabled/disabled. I would suggest to open a bug report
and add there as much info as you can find.
Cheers,
Manuel.
A bug has been filed. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61588

Andy

Loading...