On Thu, Nov 7, 2013 at 7:26 PM, Joseph S. Myers <jos...@codesourcery.com> wrote:

>> Please note that following code form fenv.c won't generate overflow
>> exception on x87:
>>
>>   if (excepts & FP_EX_OVERFLOW)
>>     {
>>       volatile float max = __FLT_MAX__;
>>       r = max * max;
>>     }
>
> r being volatile is intended to ensure that the result does get stored
> back to memory, and so in particular that a result computed with excess
> precision gets converted back to float and the exception is raised.

Can we introduce a target-dependant source here, in the same way as
gfortran has different config/fpu-*.c files? I would like to propose
the code from (recently improved) libgcc/config/i386/sfp-exceptions.c
to generate exceptions on x86 targets. The main benefits of this code
are:
- precision: it generates exactly the exception it is supposed to
generate at the exact spot (x87 and SSE)
- the code doesn't do arithemtics with denormal results
- can also generate non-standard denormal exception

Your proposed code can be considered a generic fallback code then. I'm
sure other targets have their own, perhaps better ways to generate FP
exceptions.

Uros.

Reply via email to