|
Message-ID: <20210811175723.GC13220@brightrain.aerifal.cx> Date: Wed, 11 Aug 2021 13:57:23 -0400 From: Rich Felker <dalias@...c.org> To: Stefan Kanthak <stefan.kanthak@...go.de> Cc: Szabolcs Nagy <nsz@...t70.net>, musl@...ts.openwall.com Subject: Re: [PATCH] Properly simplified nextafter() On Wed, Aug 11, 2021 at 06:50:28PM +0200, Stefan Kanthak wrote: > Rich Felker <dalias@...c.org> wrote: > > [...] > > > static __inline unsigned __FLOAT_BITS(float __f) > > { > > union {float __f; unsigned __i;} __u; > > __u.__f = __f; > > return __u.__i; > > } > > > > #define isnan(x) ( \ > > sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \ > > sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \ > > __fpclassifyl(x) == FP_NAN) > > > > So, nope. > > GCC typically uses its __builtin_isnan() for isnan(), which doesn't > use integer instructions or reloads: That's only if you #define isnan(x) __builtin_isnan(x) > $ cat isnan.c > int foo(double x) { > return isnan(x); > } > int bar(double x) { > return __builtin_isnan(x); > } > $ gcc -S -O3 -o- isnan.c > .... > xorl %eax, %eax > ucomisd %xmm0, %xmm0 > setp %al > ret > .... Which glibc, which is what you're using, does. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.