commit 56f6f6a2403cfa7267cad722597113be35ecf70d Author: Ulrich Drepper Date: Sat Jan 28 14:48:46 2012 -0500 Use -msse2avx option for x86-64 libm functions 2012-01-28 Ulrich Drepper * config.h.in: Define HAVE_SSE2AVX_SUPPORT. * math/math_private.h: Remove libc_fegetround* and libc_fesetround*. * sysdeps/i386/configure.in: Check for -msse2avx. * sysdeps/x86_64/fpu/math_private.h: Use VEX-encoded instructions also if SSE2AVX is defined. Remove libc_fegetround* and libc_fesetround*. * sysdeps/x86_64/fpu/multiarch/Makefile: Compile *-avx functions if config-cflags-sse2avx is yes. Also add -DSSE2AVX to defines. * sysdeps/x86_64/fpu/multiarch/e_atan2.c: Use HAS_AVX again instead of HAS_YMM_USABLE. * sysdeps/x86_64/fpu/multiarch/e_exp.c: Likewise. * sysdeps/x86_64/fpu/multiarch/e_log.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_atan.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_sin.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_tan.c: Likewise. diff --git a/config.h.in b/config.h.in index 50d53d4..1489476 100644 --- a/config.h.in +++ b/config.h.in @@ -90,7 +90,7 @@ certain registers (CR0, MQ, CTR, LR) in asm statements. */ #undef BROKEN_PPC_ASM_CR0 -/* Defined on SPARC if ld doesn't handle R_SPARC_WDISP22 against .hidden +/* Defined on SPARC if ld does not handle R_SPARC_WDISP22 against .hidden symbol. sysdeps/sparc/sparc32/elf/configure. */ #undef BROKEN_SPARC_WDISP22 @@ -106,17 +106,20 @@ /* Define if gcc supports AVX. */ #undef HAVE_AVX_SUPPORT +/* Define if gcc supports VEX encoding. */ +#undef HAVE_SSE2AVX_SUPPORT + /* Define if gcc supports FMA4. */ #undef HAVE_FMA4_SUPPORT -/* Define if the compiler's exception support is based on libunwind. */ +/* Define if the compiler\'s exception support is based on libunwind. */ #undef HAVE_CC_WITH_LIBUNWIND /* Define if the access to static and hidden variables is position independent and does not need relocations. */ #undef PI_STATIC_AND_HIDDEN -/* Define this to disable the `hidden_proto' et al macros in +/* Define this to disable the 'hidden_proto' et al macros in include/libc-symbols.h that avoid PLT slots in the shared objects. */ #undef NO_HIDDEN diff --git a/sysdeps/i386/configure b/sysdeps/i386/configure index ae494e2..bc7900e 100644 --- a/sysdeps/i386/configure +++ b/sysdeps/i386/configure @@ -756,6 +756,29 @@ if test $libc_cv_cc_avx = yes; then fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for AVX encoding of SSE instructions" >&5 +$as_echo_n "checking for AVX encoding of SSE instructions... " >&6; } +if ${libc_cv_cc_sse2avx+:} false; then : + $as_echo_n "(cached) " >&6 +else + if { ac_try='${CC-cc} -msse2avx -xc /dev/null -S -o /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + libc_cv_cc_sse2avx=yes +else + libc_cv_cc_sse2avx=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_sse2avx" >&5 +$as_echo "$libc_cv_cc_sse2avx" >&6; } +if test $libc_cv_cc_sse2avx = yes; then + $as_echo "#define HAVE_SSE2AVX_SUPPORT 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FMA4 support" >&5 $as_echo_n "checking for FMA4 support... " >&6; } if ${libc_cv_cc_fma4+:} false; then : diff --git a/sysdeps/i386/configure.in b/sysdeps/i386/configure.in index 5a9840e..59a4cd6 100644 --- a/sysdeps/i386/configure.in +++ b/sysdeps/i386/configure.in @@ -67,6 +67,17 @@ if test $libc_cv_cc_avx = yes; then AC_DEFINE(HAVE_AVX_SUPPORT) fi +dnl Check if -msse2avx works. +AC_CACHE_CHECK(for AVX encoding of SSE instructions, libc_cv_cc_sse2avx, [dnl +if AC_TRY_COMMAND([${CC-cc} -msse2avx -xc /dev/null -S -o /dev/null]); then + libc_cv_cc_sse2avx=yes +else + libc_cv_cc_sse2avx=no +fi]) +if test $libc_cv_cc_sse2avx = yes; then + AC_DEFINE(HAVE_SSE2AVX_SUPPORT) +fi + dnl Check if -mfma4 works. AC_CACHE_CHECK(for FMA4 support, libc_cv_cc_fma4, [dnl if AC_TRY_COMMAND([${CC-cc} -mfma4 -xc /dev/null -S -o /dev/null]); then diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index be68903..4b5c173 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -34,21 +34,21 @@ CFLAGS-s_sin-fma4.c = -mfma4 CFLAGS-s_tan-fma4.c = -mfma4 endif -ifeq ($(config-cflags-avx),yes) +ifeq ($(config-cflags-sse2avx),yes) libm-sysdep_routines += e_exp-avx e_log-avx s_atan-avx \ e_atan2-avx s_sin-avx s_tan-avx \ mplog-avx mpa-avx slowexp-avx \ mpexp-avx -CFLAGS-e_atan2-avx.c = -mavx -CFLAGS-e_exp-avx.c = -mavx -CFLAGS-e_log-avx.c = -mavx -CFLAGS-mpa-avx.c = -mavx -CFLAGS-mpexp-avx.c = -mavx -CFLAGS-mplog-avx.c = -mavx -CFLAGS-s_atan-avx.c = -mavx -CFLAGS-s_sin-avx.c = -mavx -CFLAGS-slowexp-avx.c = -mavx -CFLAGS-s_tan-avx.c = -mavx +CFLAGS-e_atan2-avx.c = -msse2avx -DSSE2AVX +CFLAGS-e_exp-avx.c = -msse2avx -DSSE2AVX +CFLAGS-e_log-avx.c = -msse2avx -DSSE2AVX +CFLAGS-mpa-avx.c = -msse2avx -DSSE2AVX +CFLAGS-mpexp-avx.c = -msse2avx -DSSE2AVX +CFLAGS-mplog-avx.c = -msse2avx -DSSE2AVX +CFLAGS-s_atan-avx.c = -msse2avx -DSSE2AVX +CFLAGS-s_sin-avx.c = -msse2avx -DSSE2AVX +CFLAGS-slowexp-avx.c = -sse2mavx -DSSE2AVX +CFLAGS-s_tan-avx.c = -msse2avx -DSSE2AVX endif endif diff --git a/sysdeps/x86_64/fpu/multiarch/e_atan2.c b/sysdeps/x86_64/fpu/multiarch/e_atan2.c index 3a615fc..6867c6e 100644 --- a/sysdeps/x86_64/fpu/multiarch/e_atan2.c +++ b/sysdeps/x86_64/fpu/multiarch/e_atan2.c @@ -14,7 +14,7 @@ extern double __ieee754_atan2_fma4 (double, double); libm_ifunc (__ieee754_atan2, HAS_FMA4 ? __ieee754_atan2_fma4 - : (HAS_YMM_USABLE ? __ieee754_atan2_avx : __ieee754_atan2_sse2)); + : (HAS_AVX ? __ieee754_atan2_avx : __ieee754_atan2_sse2)); strong_alias (__ieee754_atan2, __atan2_finite) # define __ieee754_atan2 __ieee754_atan2_sse2 diff --git a/sysdeps/x86_64/fpu/multiarch/e_exp.c b/sysdeps/x86_64/fpu/multiarch/e_exp.c index 7b2320a..3c65028 100644 --- a/sysdeps/x86_64/fpu/multiarch/e_exp.c +++ b/sysdeps/x86_64/fpu/multiarch/e_exp.c @@ -14,7 +14,7 @@ extern double __ieee754_exp_fma4 (double); libm_ifunc (__ieee754_exp, HAS_FMA4 ? __ieee754_exp_fma4 - : (HAS_YMM_USABLE ? __ieee754_exp_avx : __ieee754_exp_sse2)); + : (HAS_AVX ? __ieee754_exp_avx : __ieee754_exp_sse2)); strong_alias (__ieee754_exp, __exp_finite) # define __ieee754_exp __ieee754_exp_sse2 diff --git a/sysdeps/x86_64/fpu/multiarch/e_log.c b/sysdeps/x86_64/fpu/multiarch/e_log.c index ab277d6..05f3668 100644 --- a/sysdeps/x86_64/fpu/multiarch/e_log.c +++ b/sysdeps/x86_64/fpu/multiarch/e_log.c @@ -14,8 +14,7 @@ extern double __ieee754_log_fma4 (double); libm_ifunc (__ieee754_log, HAS_FMA4 ? __ieee754_log_fma4 - : (HAS_YMM_USABLE ? __ieee754_log_avx - : __ieee754_log_sse2)); + : (HAS_AVX ? __ieee754_log_avx : __ieee754_log_sse2)); strong_alias (__ieee754_log, __log_finite) # define __ieee754_log __ieee754_log_sse2 diff --git a/sysdeps/x86_64/fpu/multiarch/s_atan.c b/sysdeps/x86_64/fpu/multiarch/s_atan.c index 78c7e09..ae16d7c 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_atan.c +++ b/sysdeps/x86_64/fpu/multiarch/s_atan.c @@ -13,7 +13,7 @@ extern double __atan_fma4 (double); # endif libm_ifunc (atan, (HAS_FMA4 ? __atan_fma4 : - HAS_YMM_USABLE ? __atan_avx : __atan_sse2)); + HAS_AVX ? __atan_avx : __atan_sse2)); # define atan __atan_sse2 #endif diff --git a/sysdeps/x86_64/fpu/multiarch/s_sin.c b/sysdeps/x86_64/fpu/multiarch/s_sin.c index 417acd0..a0c2521 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_sin.c +++ b/sysdeps/x86_64/fpu/multiarch/s_sin.c @@ -18,11 +18,11 @@ extern double __sin_fma4 (double); # endif libm_ifunc (__cos, (HAS_FMA4 ? __cos_fma4 : - HAS_YMM_USABLE ? __cos_avx : __cos_sse2)); + HAS_AVX ? __cos_avx : __cos_sse2)); weak_alias (__cos, cos) libm_ifunc (__sin, (HAS_FMA4 ? __sin_fma4 : - HAS_YMM_USABLE ? __sin_avx : __sin_sse2)); + HAS_AVX ? __sin_avx : __sin_sse2)); weak_alias (__sin, sin) # define __cos __cos_sse2 diff --git a/sysdeps/x86_64/fpu/multiarch/s_tan.c b/sysdeps/x86_64/fpu/multiarch/s_tan.c index 3047155..904308f 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_tan.c +++ b/sysdeps/x86_64/fpu/multiarch/s_tan.c @@ -13,7 +13,7 @@ extern double __tan_fma4 (double); # endif libm_ifunc (tan, (HAS_FMA4 ? __tan_fma4 : - HAS_YMM_USABLE ? __tan_avx : __tan_sse2)); + HAS_AVX ? __tan_avx : __tan_sse2)); # define tan __tan_sse2 #endif commit 7998fa7899a29803ad4512002636332dfee48451 Author: Andreas Schwab Date: Fri Mar 16 16:07:57 2012 +0100 Disable use of FMA instructions in branred 2012-03-21 Andreas Schwab * sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines): Remove brandred-fma4. (CFLAGS-brandred-fma4.c): Remove. * sysdeps/x86_64/fpu/multiarch/brandred-fma4.c: Remove. * sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c (__branred): Don't define. * sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c (__branred): Don't define. * stdio-common/_itoa.c: Check _ITOA_NEEDED instead of diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 2a38ffc..12b0526 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -7,10 +7,9 @@ libm-sysdep_routines += e_exp-fma4 e_log-fma4 e_pow-fma4 s_atan-fma4 \ e_asin-fma4 e_atan2-fma4 s_sin-fma4 s_tan-fma4 \ mplog-fma4 mpa-fma4 slowexp-fma4 slowpow-fma4 \ sincos32-fma4 doasin-fma4 dosincos-fma4 \ - brandred-fma4 halfulp-fma4 mpexp-fma4 \ + halfulp-fma4 mpexp-fma4 \ mpatan2-fma4 mpatan-fma4 mpsqrt-fma4 mptan-fma4 -CFLAGS-brandred-fma4.c = -mfma4 CFLAGS-doasin-fma4.c = -mfma4 CFLAGS-dosincos-fma4.c = -mfma4 CFLAGS-e_asin-fma4.c = -mfma4 diff --git a/sysdeps/x86_64/fpu/multiarch/brandred-fma4.c b/sysdeps/x86_64/fpu/multiarch/brandred-fma4.c deleted file mode 100644 index f4f68ac..0000000 --- a/sysdeps/x86_64/fpu/multiarch/brandred-fma4.c +++ /dev/null @@ -1,4 +0,0 @@ -#define __branred __branred_fma4 -#define SECTION __attribute__ ((section (".text.fma4"))) - -#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c b/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c index 2501af9..4c35739 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/s_sin-fma4.c @@ -1,6 +1,5 @@ #define __cos __cos_fma4 #define __sin __sin_fma4 -#define __branred __branred_fma4 #define __docos __docos_fma4 #define __dubsin __dubsin_fma4 #define __mpcos __mpcos_fma4 diff --git a/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c b/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c index d7dab3c..a805440 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/s_tan-fma4.c @@ -1,5 +1,4 @@ #define tan __tan_fma4 -#define __branred __branred_fma4 #define __dbl_mp __dbl_mp_fma4 #define __mpranred __mpranred_fma4 #define __mptan __mptan_fma4 commit 3b1004624e54cc2fefd034ff80d5dea4b6db764f Author: Joseph Myers Date: Mon Jan 30 19:55:15 2012 +0000 Fix makefile/configure problems with sse2avx changes. 2012-01-30 Joseph Myers * configure.in (libc_cv_cc_sse2avx): AC_SUBST. * configure: Regenerate. * config.make.in (config-cflags-sse2avx): Define. * sysdeps/x86_64/fpu/multiarch/Makefile (CFLAGS-slowexp-avx.c): Fix typo. * scripts/config.guess: Update from upstream config git repository. diff --git a/config.make.in b/config.make.in index d937952..75061f6 100644 --- a/config.make.in +++ b/config.make.in @@ -36,6 +36,7 @@ asflags-cpu = @libc_cv_cc_submachine@ config-cflags-sse4 = @libc_cv_cc_sse4@ config-cflags-avx = @libc_cv_cc_avx@ +config-cflags-sse2avx = @libc_cv_cc_sse2avx@ config-cflags-novzeroupper = @libc_cv_cc_novzeroupper@ config-asflags-i686 = @libc_cv_as_i686@ diff --git a/configure b/configure index 71e8de1..508e1bb 100755 --- a/configure +++ b/configure @@ -620,6 +620,7 @@ use_ldconfig libc_cv_as_i686 libc_cv_cc_fma4 libc_cv_cc_novzeroupper +libc_cv_cc_sse2avx libc_cv_cc_avx libc_cv_cc_sse4 libc_cv_cpp_asm_debuginfo diff --git a/configure.in b/configure.in index 5fd6d85..0499d3c 100644 --- a/configure.in +++ b/configure.in @@ -2154,6 +2154,7 @@ dnl sysdeps/CPU/configure.in checks set this via arch-specific asm tests AC_SUBST(libc_cv_cpp_asm_debuginfo) AC_SUBST(libc_cv_cc_sse4) AC_SUBST(libc_cv_cc_avx) +AC_SUBST(libc_cv_cc_sse2avx) AC_SUBST(libc_cv_cc_novzeroupper) AC_SUBST(libc_cv_cc_fma4) AC_SUBST(libc_cv_as_i686) diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 4b5c173..2a38ffc 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -48,7 +48,7 @@ CFLAGS-mpexp-avx.c = -msse2avx -DSSE2AVX CFLAGS-mplog-avx.c = -msse2avx -DSSE2AVX CFLAGS-s_atan-avx.c = -msse2avx -DSSE2AVX CFLAGS-s_sin-avx.c = -msse2avx -DSSE2AVX -CFLAGS-slowexp-avx.c = -sse2mavx -DSSE2AVX +CFLAGS-slowexp-avx.c = -msse2avx -DSSE2AVX CFLAGS-s_tan-avx.c = -msse2avx -DSSE2AVX endif endif