Fix ldbl-128 built-in function use
authorJoseph Myers <joseph@codesourcery.com>
Thu, 5 Jan 2023 00:02:54 +0000 (00:02 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 5 Jan 2023 00:02:54 +0000 (00:02 +0000)
Fix the following issues with built-in function use in
sysdeps/ieee754/ldbl-128 and sysdeps/ieee754/float128:

* fabsl used __builtin_fabsf128 unconditionally, breaking the build
  with GCC 6 for several architectures; it should use __builtin_fabsl
  with an appropriate redirection in float128_private.h.  (I'm not
  particularly concerned with building glibc with GCC 6; rather, I
  want to be able to run the tgmath.h tests with GCC 6, which is a
  significantly different case for tgmath.h compared to GCC 7 and
  later because of the lack of _FloatN / _FloatNx support in the
  compiler, and at present running the tests with a compiler means
  building glibc with that compiler.)

* Some (conditional) uses of built-in functions had been added to
  ldbl-128 without appropriate float128_private.h remapping (there was
  remapping for the macros controlling whether the built-in functions
  are used, just not for the functions themselves).

* s_llrintl.c called __builtin_round not __builtin_llrintl, which is
  obviously wrong.

Tested with build-many-glibcs.py for aarch64-linux-gnu, GCC 6 (where
it fixes the glibc build) and GCC 12, and with the glibc testsuite for
x86_64.

sysdeps/ieee754/float128/float128_private.h
sysdeps/ieee754/ldbl-128/s_fabsl.c
sysdeps/ieee754/ldbl-128/s_llrintl.c

index 78107b1..b786488 100644 (file)
 #define __builtin_ceill __builtin_ceilf128
 #define __builtin_truncl __builtin_truncf128
 #define __builtin_roundl __builtin_roundf128
+#define __builtin_roundevenl __builtin_roundevenf128
+#define __builtin_lrintl __builtin_lrintf128
+#define __builtin_llrintl __builtin_llrintf128
 #define __builtin_copysignl __builtin_copysignf128
+#define __builtin_fabsl __builtin_fabsf128
 
 /* Get the constant suffix from bits/floatn-compat.h.  */
 #define L(x) __f128 (x)
index f22515f..2e5ea3f 100644 (file)
@@ -27,6 +27,6 @@ static char rcsid[] = "$NetBSD: $";
 _Float128
 __fabsl (_Float128 x)
 {
-  return __builtin_fabsf128 (x);
+  return __builtin_fabsl (x);
 }
 libm_alias_ldouble (__fabs, fabs)
index 3a5635d..22e6e5f 100644 (file)
@@ -31,7 +31,7 @@ long long int
 __llrintl (_Float128 x)
 {
 #if USE_LLRINTL_BUILTIN
-  return __builtin_round (x);
+  return __builtin_llrintl (x);
 #else
   /* Use generic implementation.  */
   static const _Float128 two112[2] =