[PATCH] middle-end: convert builtin finite -> MINUS/ORD

Ian Lance Taylor iant@google.com
Tue Jun 12 17:40:00 GMT 2007


"Kaveh R. GHAZI" <ghazi@caip.rutgers.edu> writes:

> On Tue, 12 Jun 2007, Jakub Jelinek wrote:
> 
> > AFAIK isfinite/isinf/isnan/isnormal/fpclassify/signbit aren't supposed
> > to raise exceptions even for signalling NaNs.
> > 	Jakub
> 
> In libgcc2.c, we have:
> 
> /* All of these would be present in a full C99 implementation of <math.h>
>    and <complex.h>.  Our problem is that only a few systems have such full
>    implementations.  Further, libgcc_s.so isn't currently linked against
>    libm.so, and even for systems that do provide full C99, the extra overhead
>    of all programs using libgcc having to link against libm.  So avoid it.
> */
> 
> #define isnan(x)        __builtin_expect ((x) != (x), 0)
> #define isfinite(x)     __builtin_expect (!isnan((x) - (x)), 1)
> #define isinf(x)        __builtin_expect (!isnan(x) & !isfinite(x), 0)
> 
> 
> So won't these raise exceptions as well?

Yes, but in libgcc2.c it's OK.  Those macros are only called by code
which is implementing a floating point arithmetic operation.  Those
operations should raise an exception if called with a signaling NaN
anyhow.

It's a different case when user code is calling isnan.  In that case
they should not throw an exception for a signaling NaN.

Ian



More information about the Gcc-patches mailing list