This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC beaten by ICC in stupid trig test!


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]