What is acceptable for -ffast-math? (Was: associative law incombine)
Linus Torvalds
torvalds@transmeta.com
Wed Aug 1 10:41:00 GMT 2001
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.
Linus
----
#include <math.h>
void test(double, double, double);
main()
{
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));
}
More information about the Gcc
mailing list