diff options
author | Raphael Moreira Zinsly <rzinsly@linux.ibm.com> | 2021-02-23 14:14:37 -0300 |
---|---|---|
committer | Raphael Moreira Zinsly <rzinsly@linux.ibm.com> | 2021-03-16 12:19:09 -0300 |
commit | 56c81132ccc6f468fa4fc29c536db060e18e9d87 (patch) | |
tree | 073154d30a66fb6cd09b234198b0c27a5efb36b1 /sysdeps/powerpc/powerpc64/le | |
parent | 3977477d48bc85a5719f3d54040b257cc7e85709 (diff) | |
download | glibc-56c81132ccc6f468fa4fc29c536db060e18e9d87.tar.gz glibc-56c81132ccc6f468fa4fc29c536db060e18e9d87.tar.xz glibc-56c81132ccc6f468fa4fc29c536db060e18e9d87.zip |
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/powerpc64/le')
-rw-r--r-- | sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c | 30 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/le/fpu/w_ilogbl.c | 4 |
2 files changed, 34 insertions, 0 deletions
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c new file mode 100644 index 0000000000..b5c1c0aa9d --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c @@ -0,0 +1,30 @@ +#include <math.h> +#include <errno.h> +#include <limits.h> +#include <math_private.h> +#include <fenv.h> + +#if _GL_HAS_BUILTIN_ILOGB +int +M_DECL_FUNC (__ilogb) (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); + if (__builtin_expect (r == FP_ILOGB0, 0) + || __builtin_expect (r == FP_ILOGBNAN, 0) + || __builtin_expect (r == INT_MAX, 0)) + { + __set_errno (EDOM); + __feraiseexcept (FE_INVALID); + } + return r; +} +declare_mgen_alias (__ilogb, ilogb) +#else +#include <math/w_ilogb_template.c> +#endif diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbl.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbl.c new file mode 100644 index 0000000000..205f154f00 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogbl.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_ilogb_template.c> |