------- Comment #21 from mkuvyrkov at gcc dot gnu dot org 2010-05-05 20:28 ------- Dominique,
Have you been able to identify if there is an invalid optimization? It seems using -ffast-math -ffinite-math-only is very error-prone. -ffast-math implies -fassociative-math, which can generate NaNs, and -ffinite-math-only can further worsen the precision by additional optimizations. It may not be obvious to a casual GCC user that -ffinite-math-only gives more freedom to the optimization passes, not restricts the compiler to keep all math finite. FYI, -fassociative-math Allow re-association of operands in series of floating-point operations. This violates the ISO C and C++ language standard by possibly changing computa- tion result. NOTE: re-ordering may change the sign of zero as well as ignore NaNs and inhibit or create underflow or overflow (and thus cannot be used on a code which relies on rounding behavior like (x + 2**52) - 2**52). May also reorder floating-point comparisons and thus may not be used when ordered comparisons are required. This option requires that both -fno-signed-zeros and -fno-trapping-math be in effect. Moreover, it doesnt make much sense with -frounding-math. For Fortran the option is automatically enabled when both -fno-signed-zeros and -fno-trapping-math are in effect. The default is -fno-associative-math. ... -ffinite-math-only Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or +-Infs. This option is not turned on by any -O option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ISO rules/specifications for math functions. It may, however, yield faster code for programs that do not require the guarantees of these specifications. The default is -fno-finite-math-only. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43716