From: Bruno Haible Date: Wed, 4 Oct 2023 11:12:53 +0000 (+0200) Subject: totalorderl: Optimize. X-Git-Tag: v1.0~737 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=864b6557d39dcff38784a837237776e9cc6985d9;p=gnulib.git totalorderl: Optimize. * modules/totalorderl (Files): Add m4/signbit.m4. * m4/totalorder.m4 (gl_FUNC_TOTALORDERL): Invoke gl_LONG_DOUBLE_SIGN_LOCATION. * lib/totalorderl.c (totalorderl): If LDBL_SIGNBIT_WORD is known, use it, so that 'bigendian' becomes a constant. --- diff --git a/ChangeLog b/ChangeLog index 490e32bb87..e9de2bc1d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2023-10-04 Bruno Haible + + totalorderl: Optimize. + * modules/totalorderl (Files): Add m4/signbit.m4. + * m4/totalorder.m4 (gl_FUNC_TOTALORDERL): Invoke + gl_LONG_DOUBLE_SIGN_LOCATION. + * lib/totalorderl.c (totalorderl): If LDBL_SIGNBIT_WORD is known, + use it, so that 'bigendian' becomes a constant. + 2023-10-04 Bruno Haible totalorderl: Work around Solaris cc bug. diff --git a/lib/totalorderl.c b/lib/totalorderl.c index 84fed3c4d1..cf7da088ac 100644 --- a/lib/totalorderl.c +++ b/lib/totalorderl.c @@ -73,8 +73,14 @@ totalorderl (long double const *x, long double const *y) /* Determine in which of the two 'unsigned long long' words the sign bit is located. */ + bool bigendian; +#if defined LDBL_SIGNBIT_WORD + /* We have already determined the sign bit location at configure time. */ + bigendian = (LDBL_SIGNBIT_WORD < 2); +#else zu.f = -zu.f; - bool bigendian = !!zu.i[0]; + bigendian = !!zu.i[0]; +#endif unsigned long long xhi = xu.i[!bigendian] ^ extended_sign, diff --git a/m4/totalorder.m4 b/m4/totalorder.m4 index 0bbd252675..95aab65f19 100644 --- a/m4/totalorder.m4 +++ b/m4/totalorder.m4 @@ -81,6 +81,9 @@ AC_DEFUN([gl_FUNC_TOTALORDERL], else REPLACE_TOTALORDERL=1 fi - TOTALORDERL_LIBM='$(ISNANL_LIBM)']) + TOTALORDERL_LIBM='$(ISNANL_LIBM)' + dnl Prerequisite of lib/totalorderl.c. + gl_LONG_DOUBLE_SIGN_LOCATION + ]) AC_SUBST([TOTALORDERL_LIBM]) ]) diff --git a/modules/totalorderl b/modules/totalorderl index d684c8c69c..ed6f801130 100644 --- a/modules/totalorderl +++ b/modules/totalorderl @@ -5,6 +5,7 @@ Files: lib/totalorderl.c m4/mathfunc.m4 m4/totalorder.m4 +m4/signbit.m4 Depends-on: math