aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/powerpc/fpu
diff options
context:
space:
mode:
authorRaphael Moreira Zinsly <rzinsly@linux.ibm.com>2021-02-23 14:14:37 -0300
committerRaphael Moreira Zinsly <rzinsly@linux.ibm.com>2021-03-16 12:19:09 -0300
commit56c81132ccc6f468fa4fc29c536db060e18e9d87 (patch)
tree073154d30a66fb6cd09b234198b0c27a5efb36b1 /sysdeps/powerpc/fpu
parent3977477d48bc85a5719f3d54040b257cc7e85709 (diff)
downloadglibc-56c81132ccc6f468fa4fc29c536db060e18e9d87.zip
glibc-56c81132ccc6f468fa4fc29c536db060e18e9d87.tar.gz
glibc-56c81132ccc6f468fa4fc29c536db060e18e9d87.tar.bz2
powerpc: Add optimized ilogb* for POWER9
The instructions xsxexpdp and xsxexpqp introduced on POWER9 extract the exponent from a double-precision and quad-precision floating-point respectively, thus they can be used to improve ilogb, ilogbf and ilogbf128.
Diffstat (limited to 'sysdeps/powerpc/fpu')
-rw-r--r--sysdeps/powerpc/fpu/math_private.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h
index 91b1361..21628f3 100644
--- a/sysdeps/powerpc/fpu/math_private.h
+++ b/sysdeps/powerpc/fpu/math_private.h
@@ -25,7 +25,28 @@
#include_next <math_private.h>
-#if defined _ARCH_PWR9 && __HAVE_DISTINCT_FLOAT128
+#ifdef _ARCH_PWR9
+
+#if __GNUC_PREREQ (8, 0)
+# define _GL_HAS_BUILTIN_ILOGB 1
+#elif defined __has_builtin
+# define _GL_HAS_BUILTIN_ILOGB __has_builtin (__builtin_vsx_scalar_extract_exp)
+#else
+# define _GL_HAS_BUILTIN_ILOGB 0
+#endif
+
+#define __builtin_test_dc_ilogbf __builtin_test_dc_ilogb
+#define __builtin_ilogbf __builtin_ilogb
+
+#define __builtin_test_dc_ilogb(x, y) \
+ __builtin_vsx_scalar_test_data_class_dp(x, y)
+#define __builtin_ilogb(x) __builtin_vsx_scalar_extract_exp(x) - 0x3ff
+
+#define __builtin_test_dc_ilogbf128(x, y) \
+ __builtin_vsx_scalar_test_data_class_qp(x, y)
+#define __builtin_ilogbf128(x) __builtin_vsx_scalar_extract_expq(x) - 0x3fff
+
+#if __HAVE_DISTINCT_FLOAT128
extern __always_inline _Float128
__ieee754_sqrtf128 (_Float128 __x)
{
@@ -34,5 +55,8 @@ __ieee754_sqrtf128 (_Float128 __x)
return __z;
}
#endif
+#else /* !_ARCH_PWR9 */
+#define _GL_HAS_BUILTIN_ILOGB 0
+#endif
#endif /* _PPC_MATH_PRIVATE_H_ */