This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: FENV_ACCESS questions in C and Fortran
> Date: Thu, 11 Nov 1999 07:55:36 -0500 (EST)
> From: Stephen L Moshier <moshier@mediaone.net>
> Reply-To: moshier@mediaone.net
> cc: gcc@gcc.gnu.org
>
>
> > A compiler may do any
> > transformation on a strictly conforming program so long as the program
> > behaves as if those transformations are not done.
>
> Then why do you say it is ok to eliminate exception traps? The
> behavior on floating point exception seems to be unspecified.
> Exceptions could do anything at all. How would the compiler know
> whether it is safe to touch them?
The behaviour of a FP exception is very well specified. For instance,
on an INEXACT exception, execution continues and a result is returned
in accordance with the current rounding mode. For OVERFLOW exceptions,
Inf is usually returned, and so on.
All this is discussed in the standard in section F.8, "optimization".
In particular, paragraph 3 says
This specification does not require support for trap handlers that
maintain information about the order or count of floating-point
exceptions. Therefore, between function calls, floating-point
exceptions need not be precise: the actual order and number of
occurrences of floating-point exceptions (> 1) may vary from what
the source code expresses. ...
Then they give an example of an optimisation showing this, very like
what I've posted already.
--
Geoffrey Keating <geoffk@cygnus.com>