GCC beaten by ICC in stupid trig test!
Paul Koning
pkoning@equallogic.com
Wed Mar 24 20:14:00 GMT 2004
>>>>> "Joe" == Joe Buck <Joe.Buck@synopsys.COM> writes:
Joe> It's OK for -ffast-math to make the kind of transformation that
Joe> might lose the last bit or two of an IEEE FP result. However,
Joe> disregarding parentheses will frequently throw away far more
Joe> precision than that.
Joe> Consider a, b, and c as single precision floating point values,
Joe> and a=1, b=-1, c=1.2345e-8. (a+b)+c will compute as 1.2345e-8.
Joe> a+(b+c) will return zero, as will (a+c)+b.
I don't have a C standard, but my copy of Harbison & Steele says what
I expected about parentheses: "Parentheses do not necessarily force a
particular evaluation order".
So as far as I can tell, by the language rules, (a+b)+c and a+(b+c)
are the same -- they have the same ordering properties (or lack
thereof).
Is the implication that if -fno-fast-math is in effect, parentheses
acquire an ADDITIONAL semantic (evaluation order) that goes beyond the
C language definition (forcing operand grouping)?
Curious that C++ (at least as described in Stroustrup) *does* say that
parentheses force evaluation order...
paul
More information about the Gcc
mailing list