This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization Question
- To: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Subject: Re: Optimization Question
- From: Stephen L Moshier <moshier at mediaone dot net>
- Date: Wed, 28 Jul 1999 19:47:59 -0400 (EDT)
- cc: gcc at gcc dot gnu dot org
- Reply-To: moshier at mediaone dot net
> language lawyer
Here is a quote from C9X.
GCC already conforms to this. No change is required.
[#14] EXAMPLE 5 Rearrangement for floating-point expressions
is often restricted because of limitations in precision as
well as range. The implementation cannot generally apply
the mathematical associative rules for addition or
multiplication, nor the distributive rule, because of
roundoff error, even in the absence of overflow and
underflow. Likewise, implementations cannot generally
replace decimal constants in order to rearrange expressions.
In the following fragment, rearrangements suggested by
mathematical rules for real numbers are often not valid (see
F.8).
double x, y, z;
/* ... */
x = (x * y) * z; // not equivalent to x *= y * z;
z = (x - y) + y ; // not equivalent to z = x;
z = x + x * y; // not equivalent to z = x * (1.0 + y);
y = x / 5.0; // not equivalent to y = x * 0.2;