Trying to reproduce -O1 or -O2 by listing a set of optimization flags is invalid.
a) most optimization flags are no-ops at the default -O0 (optimization disabled);
b) There are some optimizations that are enabled at a given optimization level, but do not have a named flag.
However, it is valid to say "-O2 -fno-whatever" to see if a specific optimization pass is at fault (although disabling an earlier one can hide a bug in a later one, so you can't make any firm statements).
@ James Hunt
Trying to reproduce -O1 or -O2 by listing a set of optimization flags is invalid.
a) most optimization flags are no-ops at the default -O0 (optimization disabled);
b) There are some optimizations that are enabled at a given optimization level, but do not have a named flag.
However, it is valid to say "-O2 -fno-whatever" to see if a specific optimization pass is at fault (although disabling an earlier one can hide a bug in a later one, so you can't make any firm statements).