This is the mail archive of the
mailing list for the GCC project.
Re: What is acceptable for -ffast-math? A numerical viewpoint
- To: guerby at acm 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: Sun, 5 Aug 2001 06:51:24 -0400 (EDT)
- Cc: gcc at gcc dot gnu dot org, jthorn at thp dot univie dot ac dot at
<<Following the thread there seem to be two camps that have quite
incompatible viewpoints: (1) experts, (2) other people. I suggest
the following scheme:
The point is that the rules have to be coherent and well documented and
understood. You are NOT going to achieve that unless you have input from
people who understand :-)
In particular, we need a clear set of criteria, and it is not going to be
easy to sort through them. People often ask for X in floating-point without
fully realizing the consequences of X. For example, we had at least one
person in category 2) here say that they were happy with any optimization
that would be valid for real numbers.
But that's obviously wrong (i.e. they would NOT be happy with the result).
Let's give an example of such an optimization.
Suppose you write a Newton-Raphson sqrt that iterates to exact equality on
the estimate. In many floating-point models, that's perfectly valid, and often
the most efficient represntation of the algorithm.
However, in real arithmetic, this loop would never converge. Does that mean
an optimizer is allowed to replace the loop with
L1: JMP L1
Well the answer is yes, if you accept the bogus criterion that any
transformation that would be valid for reals is valid.
Now you probably react, well of course that's nonsense. Fine, it is! But
*why* is it nonsense? Because the criterion was nonsense.
So what you need to do is to have group 2)
a) come up with a proposed "optimization"
b) by experiment, or other convincing argument, show that it is a worthwhile
optimization (any optimization should have to bear this burden) in either
saving of time or space.
Now group 1) will point out the *full* consequences of the transformation.
Once everyone understands the full consequences, then if no one is too unhappy
with the consequneces, you can include it.
P.S. In my experience, it is group 2) who get most upset with unexpected
consequences. They tend to expect that the only effect will be a little
bit of noise in the last decimal digit, and are the first to complain
loudly when turning on optimization radically changes results. The experts
of course know better what to expect, and will not be surprised (though
they may complain :-)