about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64
diff options
context:
space:
mode:
authorXiaolin Tang <tangxiaolin@loongson.cn>2022-11-23 11:44:58 +0800
committercaiyinyu <caiyinyu@loongson.cn>2022-11-29 16:00:28 +0800
commita1981ecbfd4aec84dea26936d91c8ed9164f8b13 (patch)
treed78cf6c9ba6e1b931c8ad01c9844c9665651175c /sysdeps/ieee754/dbl-64
parente1697a540c49d5bd35e84b22fcd537c14f71a4e9 (diff)
downloadglibc-a1981ecbfd4aec84dea26936d91c8ed9164f8b13.tar.gz
glibc-a1981ecbfd4aec84dea26936d91c8ed9164f8b13.tar.xz
glibc-a1981ecbfd4aec84dea26936d91c8ed9164f8b13.zip
Use GCC builtins for llrint functions if desired.
This patch is using the corresponding GCC builtin for llrintf, llrint,
llrintl and llrintf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins-function.h.

Co-Authored-By: Xi Ruoyao <xry111@xry111.site>
Diffstat (limited to 'sysdeps/ieee754/dbl-64')
-rw-r--r--sysdeps/ieee754/dbl-64/s_llrint.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_llrint.c b/sysdeps/ieee754/dbl-64/s_llrint.c
index dc8d9948df..88c8ec3624 100644
--- a/sysdeps/ieee754/dbl-64/s_llrint.c
+++ b/sysdeps/ieee754/dbl-64/s_llrint.c
@@ -25,17 +25,22 @@
 #include <math_private.h>
 #include <libm-alias-double.h>
 #include <fix-fp-int-convert-overflow.h>
-
-static const double two52[2] =
-{
-  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
-};
+#include <math-use-builtins.h>
 
 
 long long int
 __llrint (double x)
 {
+#if USE_LLRINT_BUILTIN
+  return __builtin_llrint (x);
+#else
+  /* Use generic implementation.  */
+  static const double two52[2] =
+  {
+    4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+   -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
+  };
+
   int32_t j0;
   uint32_t i1, i0;
   long long int result;
@@ -95,6 +100,7 @@ __llrint (double x)
     }
 
   return sx ? -result : result;
+#endif /* ! USE_LLRINT_BUILTIN  */
 }
 
 libm_alias_double (__llrint, llrint)