List of optimizations enabled by -O1 seems incorrect
Andrew Haley
aph@redhat.com
Thu Aug 13 19:02:00 GMT 2009
Nikos Chantziaras wrote:
> I'm trying to discover which GCC optimization is responsive for a
> runtime error reported by Valgrind:
>
> "Conditional jump or move depends on uninitialised value(s)"
>
> This pops up when compiling with -O1 and above. The code in question is
> C++ and is of this form:
>
> if (!foo && !bar)
>
> The uninitialized variable is 'bar'. However, it shouldn't be evaluated
> at all due to short-circuit if rules. Of course the optimizer is free
> to evaluate it anyway if there are no side-effects when doing so.
>
> So just out of interest, I'm trying to find out which optimization is
> responsible for this. I looked up the GCC info pages and I compiled
> with -O1 and then disabled the optimizations enabled by -O1 one by one,
> in hope to hit the one that triggers the error, until all of them were
> disabled in the end:
>
> -O1 -fno-auto-inc-dec -fno-cprop-registers -fno-dce -fno-defer-pop
> -fno-delayed-branch -fno-dse -fno-guess-branch-probability
> -fno-if-conversion2 -fno-if-conversion -fno-inline-small-functions
> -fno-ipa-pure-const -fno-ipa-reference -fno-merge-constants
> -fno-split-wide-types -fno-tree-ccp -fno-tree-ch -fno-tree-copyrename
> -fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse -fno-tree-fre
> -fno-tree-sra -fno-tree-ter -fno-unit-at-a-time
>
> However, the error still appears which makes me conclude that the above
> list of -O1 optimizations is not complete. Which ones am I missing?
Not all optimizations are switchable. If you want to know the complete
set of switches, compile with -fverbose-asm and look at the .s file.
If you really want to know when a particular optimization was done,
you'll have to look at the dumps.
Andrew.
More information about the Gcc-help
mailing list