1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00
Files
glibc/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c
Raphael Moreira Zinsly 56c81132cc 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.
2021-03-16 12:19:09 -03:00

31 lines
724 B
C

#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