On Mon, Jan 17, 2022 at 12:11:59AM +0100, FX via Gcc-patches wrote: > This patch is the third in my “signaling NaN” series. For targets with IEEE > support but without the issignaling macro in libc (i.e., everywhere except > glibc), this allows us to provide a fallback implementation. In order to keep > the code in ieee_helper.c relatively readable, I’ve put that new > implementation in a separate file, issignaling_fallback.h. > > The logic is borrowed from different routines in glibc, but gathered into a > single file and much simpler than the glibc implementation, because we do not > need to cover all the cases they have (comments with details are available in > issignaling_fallback.h). > > I can’t test this on all the targets I’d like to, obviously. But it was > tested on x86_64-pc-linux-gnu (where it doesn’t do anything), on > x86_64-pc-linux-gnu by mimicking the lack of a issignaling macro, and on > x86_64-apple-darwin (which does not have issignaling).
This doesn't seem to handle the powerpc* IBM double double long double. __LDBL_IS_IEC_60559__ isn't defined for this type, because it is far from an IEEE754 type, but it has signaling NaNs - as can be seen in glibc libc/sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c the type is a pair of doubles and whether it is a sNaN or qNaN is determined by whether the first double is a sNaN or qNaN. Ok for trunk? 2022-01-25 Jakub Jelinek <ja...@redhat.com> * ieee/issignaling_fallback.h (__issignalingl): Define for IBM extended long double are returning __issignaling on the first double. --- libgfortran/ieee/issignaling_fallback.h.jj 2022-01-25 12:14:45.404232320 +0100 +++ libgfortran/ieee/issignaling_fallback.h 2022-01-25 12:14:52.504131720 +0100 @@ -137,6 +137,19 @@ __issignalingl (long double x) return ret || (((exi & 0x7fff) == 0x7fff) && (hxi > 0xc0000000)); } +#elif (__LDBL_DIG__ == 31) + +/* Long double is 128-bit IBM extended type. */ + +static inline int +__issignalingl (long double x) +{ + union { long double value; double parts[2]; } u; + + u.value = x; + return __issignaling (u.parts[0]); +} + #elif (__LDBL_DIG__ == 33) && __LDBL_IS_IEC_60559__ /* Long double is 128-bit type. */ Jakub