gcc 4.3.1 generates code with -O3 that is more than 10 times slower than with -O0. gcc 4.2.3 does not show this behavior. I am going to attach the test case that I used to produce these numbers:
with gcc 4.2.3: ( time ./avltest-nn >/dev/null; time ./avltest-no >/dev/null; time ./avltest-on >/dev/null; time ./avltest-oo >/dev/null; ) real 0m1.112s user 0m1.028s sys 0m0.012s real 0m0.078s user 0m0.060s sys 0m0.008s real 0m0.940s user 0m0.916s sys 0m0.008s real 0m0.088s user 0m0.072s sys 0m0.004s with gcc 4.3.1: ( time ./avltest-nn >/dev/null; time ./avltest-no >/dev/null; time ./avltest-on >/dev/null; time ./avltest-oo >/dev/null; ) real 0m0.974s user 0m0.948s sys 0m0.004s real 0m12.936s user 0m12.893s sys 0m0.016s real 0m1.128s user 0m1.012s sys 0m0.000s real 0m0.104s user 0m0.076s sys 0m0.004s Here is the information about the compilers used: $ /opt2/linux/ix86/bin/g++-4.2.3 -v Using built-in specs. Target: x86_64-pc-linux-gnu Configured with: ../gcc-4.2.3/configure --program-suffix=-4.2.3 --enable-__cxa_atexit --enable-languages=c,c++,java --prefix=/opt2/linux/ix86 --target=x86_64-pc-linux-gnu --with-sysroot=/opt2/linux/ix86/gcc-sysroot --enable-version-specific-runtime-libs --enable-clocale=gnu Thread model: posix gcc version 4.2.3 $ /opt2/linux/ix86/bin/g++-4.3.1 -v Using built-in specs. Target: x86_64-pc-linux-gnu Configured with: ../gcc-4.3.1/configure --enable-targets=all --enable-multilib --enable-__cxa_atexit --enable-languages=c,c++,java --enable-version-specific-runtime-libs --disable-nls --enable-clocale=gnu --program-suffix=-4.3.1 --prefix=/opt2/linux/ix86 --target=i686-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-sysroot=/opt2/linux/ix86/gcc-sysroot Thread model: posix gcc version 4.3.1 (GCC) -- Summary: code generation regression with -O3 Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: lothar at tradescape dot biz GCC target triplet: x86_64-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36861