mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
Use GCC builtins for floor functions if desired.
This patch is using the corresponding GCC builtin for floorf, floor, floorl and floorf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@@ -31,4 +31,9 @@
|
|||||||
#define USE_RINTL_BUILTIN 0
|
#define USE_RINTL_BUILTIN 0
|
||||||
#define USE_RINTF128_BUILTIN 0
|
#define USE_RINTF128_BUILTIN 0
|
||||||
|
|
||||||
|
#define USE_FLOOR_BUILTIN 0
|
||||||
|
#define USE_FLOORF_BUILTIN 0
|
||||||
|
#define USE_FLOORL_BUILTIN 0
|
||||||
|
#define USE_FLOORF128_BUILTIN 0
|
||||||
|
|
||||||
#endif /* math-use-builtins.h */
|
#endif /* math-use-builtins.h */
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <math_private.h>
|
#include <math_private.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <libm-alias-double.h>
|
#include <libm-alias-double.h>
|
||||||
|
#include <math-use-builtins.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* floor(x)
|
* floor(x)
|
||||||
@@ -47,6 +48,10 @@
|
|||||||
double
|
double
|
||||||
__floor (double x)
|
__floor (double x)
|
||||||
{
|
{
|
||||||
|
#if USE_FLOOR_BUILTIN
|
||||||
|
return __builtin_floor (x);
|
||||||
|
#else
|
||||||
|
/* Use generic implementation. */
|
||||||
int64_t i0;
|
int64_t i0;
|
||||||
EXTRACT_WORDS64 (i0, x);
|
EXTRACT_WORDS64 (i0, x);
|
||||||
int32_t j0 = ((i0 >> 52) & 0x7ff) - 0x3ff;
|
int32_t j0 = ((i0 >> 52) & 0x7ff) - 0x3ff;
|
||||||
@@ -74,6 +79,7 @@ __floor (double x)
|
|||||||
else if (j0 == 0x400)
|
else if (j0 == 0x400)
|
||||||
return x + x; /* inf or NaN */
|
return x + x; /* inf or NaN */
|
||||||
return x;
|
return x;
|
||||||
|
#endif /* ! USE_FLOOR_BUILTIN */
|
||||||
}
|
}
|
||||||
#ifndef __floor
|
#ifndef __floor
|
||||||
libm_alias_double (__floor, floor)
|
libm_alias_double (__floor, floor)
|
||||||
|
@@ -144,6 +144,8 @@
|
|||||||
#define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN
|
#define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN
|
||||||
#undef USE_RINTL_BUILTIN
|
#undef USE_RINTL_BUILTIN
|
||||||
#define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN
|
#define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN
|
||||||
|
#undef USE_FLOORL_BUILTIN
|
||||||
|
#define USE_FLOORL_BUILTIN USE_FLOORF128_BUILTIN
|
||||||
|
|
||||||
/* IEEE function renames. */
|
/* IEEE function renames. */
|
||||||
#define __ieee754_acoshl __ieee754_acoshf128
|
#define __ieee754_acoshl __ieee754_acoshf128
|
||||||
@@ -349,6 +351,7 @@
|
|||||||
#define __builtin_signbitl __builtin_signbit
|
#define __builtin_signbitl __builtin_signbit
|
||||||
#define __builtin_nearbyintl __builtin_nearbyintf128
|
#define __builtin_nearbyintl __builtin_nearbyintf128
|
||||||
#define __builtin_rintl __builtin_rintf128
|
#define __builtin_rintl __builtin_rintf128
|
||||||
|
#define __builtin_floorl __builtin_floorf128
|
||||||
|
|
||||||
/* Get the constant suffix from bits/floatn-compat.h. */
|
/* Get the constant suffix from bits/floatn-compat.h. */
|
||||||
#define L(x) __f128 (x)
|
#define L(x) __f128 (x)
|
||||||
|
@@ -24,10 +24,15 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <math_private.h>
|
#include <math_private.h>
|
||||||
#include <libm-alias-float.h>
|
#include <libm-alias-float.h>
|
||||||
|
#include <math-use-builtins.h>
|
||||||
|
|
||||||
float
|
float
|
||||||
__floorf(float x)
|
__floorf(float x)
|
||||||
{
|
{
|
||||||
|
#if USE_FLOORF_BUILTIN
|
||||||
|
return __builtin_floorf (x);
|
||||||
|
#else
|
||||||
|
/* Use generic implementation. */
|
||||||
int32_t i0,j0;
|
int32_t i0,j0;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
GET_FLOAT_WORD(i0,x);
|
GET_FLOAT_WORD(i0,x);
|
||||||
@@ -50,6 +55,7 @@ __floorf(float x)
|
|||||||
}
|
}
|
||||||
SET_FLOAT_WORD(x,i0);
|
SET_FLOAT_WORD(x,i0);
|
||||||
return x;
|
return x;
|
||||||
|
#endif /* ! USE_FLOORF_BUILTIN */
|
||||||
}
|
}
|
||||||
#ifndef __floorf
|
#ifndef __floorf
|
||||||
libm_alias_float (__floor, floor)
|
libm_alias_float (__floor, floor)
|
||||||
|
@@ -28,9 +28,14 @@ static char rcsid[] = "$NetBSD: $";
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <math_private.h>
|
#include <math_private.h>
|
||||||
#include <libm-alias-ldouble.h>
|
#include <libm-alias-ldouble.h>
|
||||||
|
#include <math-use-builtins.h>
|
||||||
|
|
||||||
_Float128 __floorl(_Float128 x)
|
_Float128 __floorl(_Float128 x)
|
||||||
{
|
{
|
||||||
|
#if USE_FLOORL_BUILTIN
|
||||||
|
return __builtin_floorl (x);
|
||||||
|
#else
|
||||||
|
/* Use generic implementation. */
|
||||||
int64_t i0,i1,j0;
|
int64_t i0,i1,j0;
|
||||||
uint64_t i,j;
|
uint64_t i,j;
|
||||||
GET_LDOUBLE_WORDS64(i0,i1,x);
|
GET_LDOUBLE_WORDS64(i0,i1,x);
|
||||||
@@ -65,5 +70,6 @@ _Float128 __floorl(_Float128 x)
|
|||||||
}
|
}
|
||||||
SET_LDOUBLE_WORDS64(x,i0,i1);
|
SET_LDOUBLE_WORDS64(x,i0,i1);
|
||||||
return x;
|
return x;
|
||||||
|
#endif /* ! USE_FLOORL_BUILTIN */
|
||||||
}
|
}
|
||||||
libm_alias_ldouble (__floor, floor)
|
libm_alias_ldouble (__floor, floor)
|
||||||
|
@@ -34,12 +34,18 @@
|
|||||||
# define USE_RINTF_BUILTIN 1
|
# define USE_RINTF_BUILTIN 1
|
||||||
# define USE_RINTL_BUILTIN 1
|
# define USE_RINTL_BUILTIN 1
|
||||||
|
|
||||||
|
# define USE_FLOOR_BUILTIN 1
|
||||||
|
# define USE_FLOORF_BUILTIN 1
|
||||||
|
# define USE_FLOORL_BUILTIN 1
|
||||||
|
|
||||||
# if __GNUC_PREREQ (8, 0)
|
# if __GNUC_PREREQ (8, 0)
|
||||||
# define USE_NEARBYINTF128_BUILTIN 1
|
# define USE_NEARBYINTF128_BUILTIN 1
|
||||||
# define USE_RINTF128_BUILTIN 1
|
# define USE_RINTF128_BUILTIN 1
|
||||||
|
# define USE_FLOORF128_BUILTIN 1
|
||||||
# else
|
# else
|
||||||
# define USE_NEARBYINTF128_BUILTIN 0
|
# define USE_NEARBYINTF128_BUILTIN 0
|
||||||
# define USE_RINTF128_BUILTIN 0
|
# define USE_RINTF128_BUILTIN 0
|
||||||
|
# define USE_FLOORF128_BUILTIN 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -55,6 +61,11 @@
|
|||||||
# define USE_RINTL_BUILTIN 0
|
# define USE_RINTL_BUILTIN 0
|
||||||
# define USE_RINTF128_BUILTIN 0
|
# define USE_RINTF128_BUILTIN 0
|
||||||
|
|
||||||
|
# define USE_FLOOR_BUILTIN 0
|
||||||
|
# define USE_FLOORF_BUILTIN 0
|
||||||
|
# define USE_FLOORL_BUILTIN 0
|
||||||
|
# define USE_FLOORF128_BUILTIN 0
|
||||||
|
|
||||||
#endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */
|
#endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */
|
||||||
|
|
||||||
#endif /* math-use-builtins.h */
|
#endif /* math-use-builtins.h */
|
||||||
|
Reference in New Issue
Block a user