I have small program that performs much better when compiled with -O1
as opposed to no optimisation. I am interested in knowing what optimisation(s) done by the com
This is expected, not a bug: https://gcc.gnu.org/wiki/FAQ#optimization-options
Is there something else that -O1 does that isn't included in the list of optimisation flags associated with -O1 in the manual?
Yes, it turns on optimization. Specifying individual -fxxx
flags doesn't do that.
If you don't use one of the -O1
, -O2
, -O3
, -Ofast
, or -Og
optimization options (and not -O0
) then no optimization happens at all, so adjusting which optimization passes are active doesn't do anything.
To find which optimization pass makes the difference you can turn on -O1
and then disable individual optimization passes until you find the one that makes a difference.
i.e. instead of:
gcc -fxxx -fyyy -fzzz ...
Use:
gcc -O1 -fno-xxx -fno-yyy -fno-zzz ...