------- Comment #11 from janis at gcc dot gnu dot org 2008-09-24 00:16 ------- Created an attachment (id=16398) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16398&action=view) yet another C testcase
I still don't understand what's going on, but have a new testcase that demonstrates a few things. By looking at tree dumps and the generated code I see that sometimes one of the comparisions of al[0], al[1], and al[2] is skipped, which I don't understand, but apparently which one is skipped is affected by -ffast-math, or is perhaps a Heisenbug that just looks as if it's affected by -ffast-math. Some interesting output from the test: elm3b149% $GCC -v Using built-in specs. Target: powerpc64-linux Configured with: /home/janis/gcc_trunk_anonsvn/gcc/configure --prefix=/home/janis/tools/gcc-trunk-anonsvn --build=powerpc64-linux --host=powerpc64-linux --target=powerpc64-linux --with-cpu=default32 --with-as=/home/janis/tools/binutils-20080903/bin/as --with-ld=/home/janis/tools/binutils-20080903/bin/ld --enable-threads=posix --enable-shared --enable-__cxa_atexit --enable-languages=c,c++,fortran --with-gmp=/home/janis/tools/gmp-mpfr-32 --with-mpfr=/home/janis/tools/gmp-mpfr-32 --with-long-double-128 --enable-secureplt --disable-libstdcxx-pch Thread model: posix gcc version 4.4.0 20080923 (experimental) [trunk revision 140601] (GCC) elm3b149% $GCC -O1 -ffast-math 37449-3.c -lm && a.out cn = -2 neig = 3 Aborted elm3b149% $GCC -O1 37449-3.c -lm && a.out cn = -2 neig = 2 elm3b149% $GCC -DDBG -O1 -ffast-math 37449-3.c -lm && a.out cn = -2 tt = -1.0472 al[0] = 0.5 al[1] = 0.5 al[2] = -1 neig = 2 elm3b149% $GCC -DDBG -O1 37449-3.c -lm && a.out cn = -2 tt = 1.0472 al[0] = 0.5 al[1] = -1 al[2] = 0.5 neig = 2 elm3b149% $GCC -DCN=-1. -O1 -ffast-math 37449-3.c -lm && a.out cn = -1 neig = 2 This won't make sense without looking at the testcase, but the test should get the same result whenever cn = -1., but it gets different results for -1. and -2., going through different paths through the generated code. Notice also that the values of the array al[] are switched around depending on the options used. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37449