From: Raphael Moreira Zinsly Date: Thu, 25 Feb 2021 12:58:52 +0000 (-0300) Subject: powerpc: Add optimized llogb* for POWER9 X-Git-Tag: glibc-2.34~823 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7d88506c260e7a0e4268803e76fc19e38ed041f;p=thirdparty%2Fglibc.git 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 --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 00000000000..d00b71d2a34 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_llogb_template.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include + +#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 +#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 00000000000..69477a37ae8 --- /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 +#include