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: FENV_ACCESS questions in C and Fortran




On 6 Nov 1999, Geoff Keating wrote:

>   feraiseexcept (FE_INEXACT);
>   do {
>     a[i] = 0.9999... * b[i];
>     i++;
>   } while (i < n);

The original program

   p = 0.1;
   for (i = 0; i < n; i++)
      a[i] = 10.0 * p * b[i];

raises an exception every time through the do-loop. The trap handler
might clear the flag and get another trap the next time through the
loop.  But the hoisted program raises only one exception.  To me, that
is a clear difference in behavior.  There ought to be a reason why
that is ok or not ok.  I don't see an explanation of why the
transformation would be considered legitimate.  Considering that
the IEEE exceptions have unknown side effects, maybe there is a story
to the effect that hoisting is improper here.

As for the compiler generating a library call to feraiseexcept, we
cannot expect every operating system to support it, and we aren't
ready to teach every gcc backend how to do that function.  If such
functions are introduced, they would want to be optional such that the
generated code is ok if the function is available and also ok if it is
not available.  We can implement the default method to begin with,
and add the fancy alternative method later.


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