This is the mail archive of the
mailing list for the GCC project.
Re: What is acceptable for -ffast-math? (Was: associative law incombine)
- To: Gabriel Dos_Reis <gdosreis at sophia dot inria dot fr>
- Subject: Re: What is acceptable for -ffast-math? (Was: associative law incombine)
- From: Linus Torvalds <torvalds at transmeta dot com>
- Date: Wed, 1 Aug 2001 10:38:20 -0700 (PDT)
- cc: <dewar at gnat dot com>, <Theodore dot Papadopoulo at sophia dot inria dot fr>, <gdr at codesourcery dot com>, <amylaar at redhat dot com>, <aoliva at redhat dot com>, <gcc at gcc dot gnu dot org>, <moshier at moshier dot ne dot mediaone dot net>, <tprince at computer dot org>
On Wed, 1 Aug 2001, Gabriel Dos_Reis wrote:
> Do you think changing 0.125 to 0.0 is not drastic?
Ehh. It's 0.125 to 0.125.
Try it yourself.
That's not a "drastic difference", not if you actually do what I
explained. If you don't have access to a x86 machine, maybe you can ask
somebody else to test the following appended for you.
Surprise, surprise, they come out exactly the same. Even down to the bit
representation (in case you care).
Not that I'm arguing that they will _always_ be the same down to the ULP,
but I _am_ arguing that at least on x86 it's actually a safe optimization.
You should disable it for -mieee.
void test(double, double, double);
test(0.5*DBL_MAX, 2*sqrt(DBL_MAX), 2*sqrt(DBL_MAX));
void test(double a, double b, double c)
printf("%f\n%f\n", a/b/c, a/(b*c));