List of optimizations enabled by -O1 seems incorrect

Nikos Chantziaras realnc@arcor.de
Thu Aug 13 18:25:00 GMT 2009


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?

I tested with GCC 4.3.4 and 4.4.1.



More information about the Gcc-help mailing list