]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use -msse2avx option for x86-64 libm functions
authorUlrich Drepper <drepper@gmail.com>
Sat, 28 Jan 2012 19:48:46 +0000 (14:48 -0500)
committerCarlos O'Donell <carlos_odonell@mentor.com>
Fri, 25 May 2012 11:05:35 +0000 (07:05 -0400)
(cherry picked from commit 56f6f6a2403cfa7267cad722597113be35ecf70d)

13 files changed:
ChangeLog
config.h.in
math/math_private.h
sysdeps/i386/configure
sysdeps/i386/configure.in
sysdeps/x86_64/fpu/math_private.h
sysdeps/x86_64/fpu/multiarch/Makefile
sysdeps/x86_64/fpu/multiarch/e_atan2.c
sysdeps/x86_64/fpu/multiarch/e_exp.c
sysdeps/x86_64/fpu/multiarch/e_log.c
sysdeps/x86_64/fpu/multiarch/s_atan.c
sysdeps/x86_64/fpu/multiarch/s_sin.c
sysdeps/x86_64/fpu/multiarch/s_tan.c

index 911a76182cc2ac381a5484ba92df18a2e1b4da23..fbbcd0a3131ab7292526359a3ff693bf8d910bf1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        ARENA_TEST says not to.  Simplify test for creation of a new arena.
        Partially based on a patch by Siddhesh Poyarekar <siddhesh@redhat.com>.
 
+2012-01-28  Ulrich Drepper  <drepper@gmail.com>
+
+       * 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.
+
+       * sysdeps/x86_64/fpu/math_private.h: Simplify use of AVX instructions.
+
 2012-01-28  Chris Metcalf  <cmetcalf@tilera.com>
 
        * scripts/firstversions.awk: Fix bug in version range handling.
index 7db663025a741ead7bee1ede61ad4fa1a7eca5b7..dc5a32013b9f70fe96dccb3f469950899b52fcdc 100644 (file)
    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
 
 /* 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
 
index 04c112fd606e430d1743fe96f4ad3a4032245c02..82c6f8040a5d3956c7f5aebc300cc289560184fa 100644 (file)
@@ -365,14 +365,6 @@ extern void __docos (double __x, double __dx, double __v[]);
    know what operations are going to be performed.  Therefore we
    define additional interfaces.  By default they refer to the normal
    interfaces.  */
-#define libc_fegetround() fegetround ()
-#define libc_fegetroundf() fegetround ()
-#define libc_fegetroundl() fegetround ()
-
-#define libc_fesetround(r) (void) fesetround (r)
-#define libc_fesetroundf(r) (void) fesetround (r)
-#define libc_fesetroundl(r) (void) fesetround (r)
-
 #define libc_feholdexcept(e) (void) feholdexcept (e)
 #define libc_feholdexceptf(e) (void) feholdexcept (e)
 #define libc_feholdexceptl(e) (void) feholdexcept (e)
index ae494e27125f18318eb3a2f1ea1633014e31cc86..bc7900ee2e4c3308183d4cb65929bb2f442d65da 100644 (file)
@@ -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 :
index 5a9840e16c6b64f5d3d5d19acc41b823c618389a..59a4cd6ea1bc87b4352b952a96d1fc8e543f5a2e 100644 (file)
@@ -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
index 7f52d5ee5f764b3b0d1754d32edd46777f07489e..3929b6b86a84e54895046ce08003199352f6dd05 100644 (file)
@@ -19,7 +19,7 @@
 
 /* We can do a few things better on x86-64.  */
 
-#ifdef __AVX__
+#if defined __AVX__ || defined SSE2AVX
 # define MOVD "vmovd"
 #else
 # define MOVD "movd"
@@ -86,7 +86,7 @@
   ({ int __di; GET_FLOAT_WORD (__di, (float) d);                             \
      (__di & 0x7fffffff) < 0x7f800000; })
 
-#ifdef __AVX__
+#if defined __AVX__ || defined SSE2AVX
 # define __ieee754_sqrt(d) \
   ({ double __res;                                                           \
     asm ("vsqrtsd %1, %0, %0" : "=x" (__res) : "xm" ((double) (d)));         \
 
 #ifdef __SSE4_1__
 # ifndef __rint
-#  ifdef __AVX__
+#  if defined __AVX__ || defined SSE2AVX
 #   define __rint(d) \
   ({ double __res; \
     asm ("vroundsd $4, %1, %0, %0" : "=x" (__res) : "xm" ((double) (d)));      \
 #  endif
 # endif
 # ifndef __rintf
-#  ifdef __AVX__
+#  if defined __AVX__ || defined SSE2AVX
 #   define __rintf(d) \
   ({ float __res; \
     asm ("vroundss $4, %1, %0, %0" : "=x" (__res) : "xm" ((float) (d)));      \
 # endif
 
 # ifndef __floor
-#  ifdef __AVX__
+#  if defined __AVX__ || defined SSE2AVX
 #   define __floor(d) \
   ({ double __res; \
     asm ("vroundsd $1, %1, %0, %0" : "=x" (__res) : "xm" ((double) (d)));      \
 #  endif
 # endif
 # ifndef __floorf
-#  ifdef __AVX__
+#  if defined __AVX__ || defined SSE2AVX
 #   define __floorf(d) \
   ({ float __res; \
     asm ("vroundss $1, %1, %0, %0" : "=x" (__res) : "xm" ((float) (d)));      \
 
 /* Specialized variants of the <fenv.h> interfaces which only handle
    either the FPU or the SSE unit.  */
-#undef libc_fegetround
-#define libc_fegetround() \
-  ({                                                                         \
-     unsigned int mxcsr;                                                     \
-     asm volatile ("stmxcsr %0" : "=m" (*&mxcsr));                           \
-     (mxcsr & 0x6000) >> 3;                                                  \
-  })
-#undef libc_fegetroundf
-#define libc_fegetroundf() libc_fegetround ()
-// #define libc_fegetroundl() fegetround ()
-
-#undef libc_fesetround
-#define libc_fesetround(r) \
-  do {                                                                       \
-     unsigned int mxcsr;                                                     \
-     asm ("stmxcsr %0" : "=m" (*&mxcsr));                                    \
-     mxcsr = (mxcsr & ~0x6000) | ((r) << 3);                                 \
-     asm volatile ("ldmxcsr %0" : : "m" (*&mxcsr));                          \
-  } while (0)
-#undef libc_fesetroundf
-#define libc_fesetroundf(r) libc_fesetround (r)
-// #define libc_fesetroundl(r) (void) fesetround (r)
-
 #undef libc_feholdexcept
 #ifdef __AVX__
 # define libc_feholdexcept(e) \
index be689036dca2cccc6a77f8ca2afa6c7fca8cbf5a..4b5c173145a8363231daf845d88dda548bd74123 100644 (file)
@@ -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
index 3a615fc9d1de012f0ff154cb68737b2db601df88..6867c6e64ec3bf11e57954734f4983ed1ed43bbb 100644 (file)
@@ -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
index 7b2320a22374e6bcf9e6e83b2935c3db1b4c7432..3c650287c542e0c137ac978ab3ef29b26612d53a 100644 (file)
@@ -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
index ab277d67fea3c09930525b89038263209c642438..05f36680be335074483540275794477daa946f6e 100644 (file)
@@ -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
index 78c7e099cb44b273590bb4aec224f80c0831bcd0..ae16d7c9bb645e21997ad74330e6a75d6dc54384 100644 (file)
@@ -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
index 417acd068312c94318d091a2c8941bd266459554..a0c2521c983df9e3fd5a2f3b0e5f85a3e060a0e9 100644 (file)
@@ -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
index 3047155cece2c0476fbfbe7a73576de5d8308513..904308fadad9b640cfaa6ae5bab32252cdd96aa2 100644 (file)
@@ -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