mirror of git://sourceware.org/git/glibc.git
math: Fix x86_64 build for -Os (BZ 33367)
The compiler might not inline the trunc function call for USE_TRUNC_BUILTIN [1]. This patch adds an optimized __trunc/__truncf for x86 used on modf ifunc variant to avoid the trunc libcall. Checked on x86_64, x86_64-v2, x86_64-v3, and x86_64-v4. Used -O2 and -Os options. Performed a full make check on x86_64 with both optimizations. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121861 Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
parent
f0b88eb784
commit
b5d88fa6c3
|
|
@ -19,6 +19,7 @@
|
||||||
#ifndef X86_MATH_PRIVATE_H
|
#ifndef X86_MATH_PRIVATE_H
|
||||||
#define X86_MATH_PRIVATE_H 1
|
#define X86_MATH_PRIVATE_H 1
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include_next <math_private.h>
|
#include_next <math_private.h>
|
||||||
|
|
||||||
__extern_always_inline long double
|
__extern_always_inline long double
|
||||||
|
|
@ -29,4 +30,30 @@ __NTH (__ieee754_atan2l (long double y, long double x))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__extern_always_inline double
|
||||||
|
__trunc (double x)
|
||||||
|
{
|
||||||
|
#ifdef __AVX__
|
||||||
|
asm ("vroundsd $11, %1, %1, %0" : "=v" (x) : "v" (x));
|
||||||
|
#elif defined __SSE4_1__
|
||||||
|
asm ("roundsd $11, %1, %0" : "=x" (x) : "x" (x));
|
||||||
|
#else
|
||||||
|
x = trunc (x);
|
||||||
|
#endif
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
__extern_always_inline float
|
||||||
|
__truncf (float x)
|
||||||
|
{
|
||||||
|
#ifdef __AVX__
|
||||||
|
asm ("vroundss $11, %1, %1, %0" : "=v" (x) : "v" (x));
|
||||||
|
#elif defined __SSE4_1__
|
||||||
|
asm ("roundss $11, %1, %0" : "=x" (x) : "x" (x));
|
||||||
|
#else
|
||||||
|
x = truncf (x);
|
||||||
|
#endif
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
#include <math_private.h>
|
||||||
|
|
||||||
#define __modf __modf_avx
|
#define __modf __modf_avx
|
||||||
|
#define trunc __trunc
|
||||||
|
|
||||||
#include <sysdeps/ieee754/dbl-64/s_modf.c>
|
#include <sysdeps/ieee754/dbl-64/s_modf.c>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
#include <math_private.h>
|
||||||
|
|
||||||
#define __modf __modf_sse41
|
#define __modf __modf_sse41
|
||||||
|
#define trunc __trunc
|
||||||
|
|
||||||
#include <sysdeps/ieee754/dbl-64/s_modf.c>
|
#include <sysdeps/ieee754/dbl-64/s_modf.c>
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,6 @@ libm_alias_double (__modf, modf)
|
||||||
# define __modf __modf_sse2
|
# define __modf __modf_sse2
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
#include <math_private.h>
|
||||||
|
#define trunc __trunc
|
||||||
#include <sysdeps/ieee754/dbl-64/s_modf.c>
|
#include <sysdeps/ieee754/dbl-64/s_modf.c>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
#include <math_private.h>
|
||||||
|
|
||||||
#define __modff __modff_avx
|
#define __modff __modff_avx
|
||||||
|
#define truncf __truncf
|
||||||
|
|
||||||
#include <sysdeps/ieee754/flt-32/s_modff.c>
|
#include <sysdeps/ieee754/flt-32/s_modff.c>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
#include <math_private.h>
|
||||||
|
|
||||||
#define __modff __modff_sse41
|
#define __modff __modff_sse41
|
||||||
|
#define truncf __truncf
|
||||||
|
|
||||||
#include <sysdeps/ieee754/flt-32/s_modff.c>
|
#include <sysdeps/ieee754/flt-32/s_modff.c>
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,6 @@ libm_alias_float (__modf, modf)
|
||||||
# define __modff __modff_sse2
|
# define __modff __modff_sse2
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
#include <math_private.h>
|
||||||
|
#define truncf __truncf
|
||||||
#include <sysdeps/ieee754/flt-32/s_modff.c>
|
#include <sysdeps/ieee754/flt-32/s_modff.c>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue