public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] powerpc: Add optimized llogb* for POWER9
@ 2021-03-16 16:19 Raphael Zinsly
  0 siblings, 0 replies; only message in thread
From: Raphael Zinsly @ 2021-03-16 16:19 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a7d88506c260e7a0e4268803e76fc19e38ed041f

commit a7d88506c260e7a0e4268803e76fc19e38ed041f
Author: Raphael Moreira Zinsly <rzinsly@linux.ibm.com>
Date:   Thu Feb 25 09:58:52 2021 -0300

    powerpc: Add optimized llogb* for POWER9
    
    The POWER9 builtins used to improve the ilogb* functions can be
    used in the llogb* functions as well.

Diff:
---
 .../powerpc/powerpc64/le/fpu/w_llogb_template.c    | 39 ++++++++++++++++++++++
 sysdeps/powerpc/powerpc64/le/fpu/w_llogbl.c        |  4 +++
 2 files changed, 43 insertions(+)

diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_llogb_template.c b/sysdeps/powerpc/powerpc64/le/fpu/w_llogb_template.c
new file mode 100644
index 0000000000..d00b71d2a3
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/w_llogb_template.c
@@ -0,0 +1,39 @@
+#include <math.h>
+#include <errno.h>
+#include <limits.h>
+#include <math_private.h>
+#include <fenv.h>
+
+#if _GL_HAS_BUILTIN_ILOGB
+long int
+M_DECL_FUNC (__llogb) (FLOAT x)
+{
+  int r;
+  /* Check for exceptional cases.  */
+  if (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f))
+    r = M_SUF (__builtin_ilogb) (x);
+  else
+    /* Fallback to the generic ilogb if x is NaN, Inf or subnormal.  */
+    r = M_SUF (__ieee754_ilogb) (x);
+  long int lr = r;
+  if (__glibc_unlikely (r == FP_ILOGB0)
+      || __glibc_unlikely (r == FP_ILOGBNAN)
+      || __glibc_unlikely (r == INT_MAX))
+    {
+#if LONG_MAX != INT_MAX
+      if (r == FP_ILOGB0)
+	lr = FP_LLOGB0;
+      else if (r == FP_ILOGBNAN)
+	lr = FP_LLOGBNAN;
+      else
+	lr = LONG_MAX;
+#endif
+      __set_errno (EDOM);
+      __feraiseexcept (FE_INVALID);
+    }
+  return lr;
+}
+declare_mgen_alias (__llogb, llogb)
+#else
+#include <math/w_llogb_template.c>
+#endif
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_llogbl.c b/sysdeps/powerpc/powerpc64/le/fpu/w_llogbl.c
new file mode 100644
index 0000000000..69477a37ae
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/w_llogbl.c
@@ -0,0 +1,4 @@
+/* Skip the optimization for long double as ibm128 does not provide an
+   optimized builtin. */
+#include <math-type-macros-ldouble.h>
+#include <math/w_llogb_template.c>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-16 16:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 16:19 [glibc] powerpc: Add optimized llogb* for POWER9 Raphael Zinsly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).