This is the mail archive of the
mailing list for the GCC project.
Re: What is acceptable for -ffast-math? A numerical viewpoint
- To: gcc at gcc dot gnu dot org, jthorn at galileo dot thp dot univie dot ac dot at
- Subject: Re: What is acceptable for -ffast-math? A numerical viewpoint
- From: dewar at gnat dot com
- Date: Sat, 4 Aug 2001 06:08:12 -0400 (EDT)
- Cc: jthorn at thp dot univie dot ac dot at
<<For (binary) IEEE arithmetic, transforming (...)/2.0 into (...)*0.5
won't change program results, because 1/2 is an exactly representatable
(binary) IEEE floating point number and IEEE specifies that the result
is the true mathematical result (identical in both cases precisely because
1/2 is exactly representable) rounded to the destination format. (I think
this argument is still valid even in the presence of +/- 0, +/-infinity,
and NAN.) So, I would argue that gcc could reasonably leave this
transformation enabled by default. (We could of course also provide a
"do arithmetic exactly as I wrote it" mode which disables this.)
But cases where the result is guaranteed the same are of COURSE fair game
for the code generoator to do what it likes. There is no sense in which the
use of the / operator specifies that a division instruction must be generated
(indeed such a rule is nonsense on a machine like the i860 which has no
division instruction :-) So we aren't discussing cases like this at all.
Yes, indeed the reciprocal transformation where it is safe is a routine
transformation that any decent code generator should do all the time.