This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Floating point performance issue
On 2011-12-26 08:22:11 -0500, Tim Prince wrote:
> On 12/26/2011 7:59 AM, Vincent Lefevre wrote:
> >On 2011-12-26 12:37:27 +0100, David Brown wrote:
> >>If it matters that "a + b - c" be calculated "(a + b) - c" or "a + (b - c)",
> >>then use brackets.
> >
> >but brackets shouldn't change anything with -fassociative-math.
> >
> >In C, brackets are purely syntactic, i.e. a + b - c is equivalent
> >to (a + b) - c.
> This was so prior to 1989, but the rules changed with the advent of ISO
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> standards. Even where compilers support algebraic simplification across
> parentheses in violation of the standards, the results are unreliable as
> well as non-portable.
Wrong! The ISO C standard even gives an example (5.1.2.3p14) saying
that an expression like a + b - c is equivalent to (a + b) - c.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)