In the following code the repeated multiplication is folded into a single operation
(multiplication by Infinity).
For different values of "x" this leads to undeserved or absent floating point
exceptions, and
breaks some of the elementary math functions in Libm. Occurs at optimization O1 and
higher.
static const double C = 0x1.0p1023;
double foo(double x)
{
return ( ( (x * C) * C ) * C );
}
--
Summary: gcc-4.0 should not reassociate floating point add or
multiplication
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P1
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fjahanian at apple dot com
CC: gcc-bugs at gcc dot gnu dot org,roger at eyesopen dot
com
GCC build triplet: powerpc-apple-darwin
GCC host triplet: powerpc-apple-darwin
GCC target triplet: powerpc-apple-darwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17892