]> Savannah Git Hosting - gnulib.git/commitdiff
totalorderl: Optimize.
authorBruno Haible <bruno@clisp.org>
Wed, 4 Oct 2023 11:12:53 +0000 (13:12 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 4 Oct 2023 11:12:53 +0000 (13:12 +0200)
* 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.

ChangeLog
lib/totalorderl.c
m4/totalorder.m4
modules/totalorderl

index 490e32bb875a91de1b5d115868aa095bcf6f5291..e9de2bc1d0beef022f66d3233f0e2e0b41cbe91a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-10-04  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        totalorderl: Work around Solaris cc bug.
index 84fed3c4d1d26b3884ff79fae83e51b234d20631..cf7da088accb515cdcf412d6b47457eb690d69d7 100644 (file)
@@ -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,
index 0bbd2526750088588d06f7626276310c79c76961..95aab65f193a7eed9ae08daf00d8b0b30f8e6adb 100644 (file)
@@ -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])
 ])
index d684c8c69cc46f1cad658f932487c57b325d029e..ed6f8011308f5c3df990c694f2c95c8c8b4e287d 100644 (file)
@@ -5,6 +5,7 @@ Files:
 lib/totalorderl.c
 m4/mathfunc.m4
 m4/totalorder.m4
+m4/signbit.m4
 
 Depends-on:
 math