This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Draft "Unsafe fp optimizations" project description.


Tim asks:

<<Are you suggesting that abrupt underflow, on systems which
have such an option, should be a -ffast-math option?
>>

First, a general point, I think it is important that everyone looking
at this issue be sure they understand the importance of denormals. Some
of the input has been in the "well I don't see it could make much difference
whether I get denormals or abrupt underflow", and if that were generally
true, the argument for putting denormals into IEEE would never have succeeded,
since it was strongly opposed by hardware designers. The burden of proof
of utility for denormals was pretty heavy, but met, so it is a good idea
to fully understand the issue.

Going to your question, we have three kinds of machines

1. Those that do denormals with little or no penalty, in this case the
issue does not arise at all.

2. Machines like the R10K where providing full denormal support is out of
the question. In this case, the discussion is whether -mieee should go into
super expensive emulation mode. Certainly we do not expect other than abrupt
underflow in either the default or -ffast-math mode.

3. Machines where denormals are possible but have a penalty. THe issue of
course is how great is the penalty. Certainly one can write programs that
work with abrupt underflow. The analysis of such programs is very much
harder, but it is possible, and many codes in practice will not be affected
much by the choice. Denormals are about ease of analysis as well as actual
improved performance, and of course if you don't analyze your program in any
case, ease of analysis is not an issue :-)

The question on type 3 machines is whether abrupt underflow should be the
default, or only available in -ffast-math mode. My answer is that it depends.

If the penalty is high, then there is a reasonable argument to put proper
denormals under control of -mieee. I think the alpha falls into that
category, and that's what we do in GNAT (we can only pass the oficial
floating-point tests in -mieee mode, but in default mode, we do not get
proper denormals).

If the penalty is low, then perhaps it is reasonable to do denormals by
default and do abrupt underflow in -ffast-math. 

I don't think there is a one-size-fits-all answer to this question.

Note that this is also influenced by what other things are done in
-ffast-math and in -mieee. I would definitely think that whatever the
choice is for a type 3 machine, the switch to control correct denormal
behavior should be separately controllable.

I would repeat the entire above discussion for "proper" handling of
negative zeroes.

By the way, it is very useful to have attributes or queries of some kind
that tell a program whether it has proper denormals and signed zeroes. In
Ada these attributes are defined in the standard (S'Denorm and
S'Signed_Zeros).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]