public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Add optimized ilogbf128 for POWER9
@ 2020-12-22 15:30 Raphael Moreira Zinsly
  2020-12-22 15:30 ` [PATCH 2/2] benchtests: Add ilogbf128 test Raphael Moreira Zinsly
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Raphael Moreira Zinsly @ 2020-12-22 15:30 UTC (permalink / raw)
  To: libc-alpha; +Cc: tuliom, Raphael Moreira Zinsly

The instruction xsxexpqp introduced on POWER9 extracts the exponent
from a quad-precision floating-point, thus it can be used to improve
ilogbf128 and llogbf128.
---
 .../powerpc/powerpc64/le/fpu/e_ilogbf128.c    | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c

diff --git a/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c b/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c
new file mode 100644
index 0000000000..47558bbadc
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/le/fpu/e_ilogbf128.c
@@ -0,0 +1,22 @@
+#ifdef _ARCH_PWR9
+int _ilogbf128 (_Float128 __x);
+
+int
+#if defined(_F128_ENABLE_IFUNC)
+__ieee754_ilogbf128_power9 (_Float128 __x)
+#else
+__ieee754_ilogbf128 (_Float128 __x)
+#endif
+{
+  /* Check for exceptional cases.  */
+  if (!__builtin_vsx_scalar_test_data_class_qp (__x, 0x7f))
+    return __builtin_vsx_scalar_extract_expq (__x) - 0x3fff;
+  else
+    /* Fallback to the generic ilogb if __x is NaN, Inf or subnormal.  */
+    return _ilogbf128(__x);
+}
+
+#define __ieee754_ilogbf128 _ilogbf128
+#endif
+
+#include<sysdeps/ieee754/float128/e_ilogbf128.c>
-- 
2.29.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-05 18:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 15:30 [PATCH] powerpc: Add optimized ilogbf128 for POWER9 Raphael Moreira Zinsly
2020-12-22 15:30 ` [PATCH 2/2] benchtests: Add ilogbf128 test Raphael Moreira Zinsly
2020-12-22 15:36 ` [PATCH] powerpc: Add optimized ilogbf128 for POWER9 Raphael M Zinsly
2021-01-04 23:20 ` Paul E Murphy
2021-01-05 18:19   ` Paul E Murphy

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).