summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2012-01-28 11:19:06 -0500
committerUlrich Drepper <drepper@gmail.com>2012-01-28 11:19:06 -0500
commit73139a7628c424c82eb9297ccb5505c0bc5b65aa (patch)
treed217ba63ff6faa36a7c477e3e900e60cef762cd1
parentd73f93a4613a7deb35abd2de4c8df7378d81ee8f (diff)
downloadglibc-73139a7628c424c82eb9297ccb5505c0bc5b65aa.tar.gz
glibc-73139a7628c424c82eb9297ccb5505c0bc5b65aa.tar.xz
glibc-73139a7628c424c82eb9297ccb5505c0bc5b65aa.zip
Simplify use of AVX instructions in internal math macros
-rw-r--r--ChangeLog4
-rw-r--r--sysdeps/x86_64/fpu/math_private.h79
2 files changed, 24 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index fcec884023..fbc611b222 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-01-28  Ulrich Drepper  <drepper@gmail.com>
+
+	* sysdeps/x86_64/fpu/math_private.h: Simplify use of AVX instructions.
+
 2012-01-19  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
 	* sysdeps/powerpc/powerpc32/a2/memcpy.S: Fix for when cache line
diff --git a/sysdeps/x86_64/fpu/math_private.h b/sysdeps/x86_64/fpu/math_private.h
index 7f52d5ee5f..50f765ff2f 100644
--- a/sysdeps/x86_64/fpu/math_private.h
+++ b/sysdeps/x86_64/fpu/math_private.h
@@ -21,8 +21,12 @@
 
 #ifdef __AVX__
 # define MOVD "vmovd"
+# define STMXCSR "vstmxcsr"
+# define LDMXCSR "vldmxcsr"
 #else
 # define MOVD "movd"
+# define STMXCSR "stmxcsr"
+# define LDMXCSR "ldmxcsr"
 #endif
 
 /* Direct movement of float into integer register.  */
@@ -173,7 +177,7 @@
 #define libc_fegetround() \
   ({									      \
      unsigned int mxcsr;						      \
-     asm volatile ("stmxcsr %0" : "=m" (*&mxcsr));			      \
+     asm volatile (STMXCSR " %0" : "=m" (*&mxcsr));			      \
      (mxcsr & 0x6000) >> 3;						      \
   })
 #undef libc_fegetroundf
@@ -184,106 +188,63 @@
 #define libc_fesetround(r) \
   do {									      \
      unsigned int mxcsr;						      \
-     asm ("stmxcsr %0" : "=m" (*&mxcsr));				      \
+     asm (STMXCSR " %0" : "=m" (*&mxcsr));				      \
      mxcsr = (mxcsr & ~0x6000) | ((r) << 3);				      \
-     asm volatile ("ldmxcsr %0" : : "m" (*&mxcsr));			      \
+     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) \
-  do {									      \
-     unsigned int mxcsr;						      \
-     asm ("vstmxcsr %0" : "=m" (*&mxcsr));				      \
-     (e)->__mxcsr = mxcsr;						      \
-     mxcsr = (mxcsr | 0x1f80) & ~0x3f;					      \
-     asm volatile ("vldmxcsr %0" : : "m" (*&mxcsr));			      \
-  } while (0)
-#else
-# define libc_feholdexcept(e) \
+#define libc_feholdexcept(e) \
   do {									      \
      unsigned int mxcsr;						      \
-     asm ("stmxcsr %0" : "=m" (*&mxcsr));				      \
+     asm (STMXCSR " %0" : "=m" (*&mxcsr));				      \
      (e)->__mxcsr = mxcsr;						      \
      mxcsr = (mxcsr | 0x1f80) & ~0x3f;					      \
-     asm volatile ("ldmxcsr %0" : : "m" (*&mxcsr));			      \
+     asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr));			      \
   } while (0)
-#endif
 #undef libc_feholdexceptf
 #define libc_feholdexceptf(e) libc_feholdexcept (e)
 // #define libc_feholdexceptl(e) (void) feholdexcept (e)
 
 #undef libc_feholdexcept_setround
-#ifdef __AVX__
-# define libc_feholdexcept_setround(e, r) \
-  do {									      \
-     unsigned int mxcsr;						      \
-     asm ("vstmxcsr %0" : "=m" (*&mxcsr));				      \
-     (e)->__mxcsr = mxcsr;						      \
-     mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | ((r) << 3);			      \
-     asm volatile ("vldmxcsr %0" : : "m" (*&mxcsr));			      \
-  } while (0)
-#else
-# define libc_feholdexcept_setround(e, r) \
+#define libc_feholdexcept_setround(e, r) \
   do {									      \
      unsigned int mxcsr;						      \
-     asm ("stmxcsr %0" : "=m" (*&mxcsr));				      \
+     asm (STMXCSR " %0" : "=m" (*&mxcsr));				      \
      (e)->__mxcsr = mxcsr;						      \
      mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | ((r) << 3);			      \
-     asm volatile ("ldmxcsr %0" : : "m" (*&mxcsr));			      \
+     asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr));			      \
   } while (0)
-#endif
 #undef libc_feholdexcept_setroundf
 #define libc_feholdexcept_setroundf(e, r) libc_feholdexcept_setround (e, r)
 // #define libc_feholdexcept_setroundl(e, r) ...
 
 #undef libc_fetestexcept
-#ifdef __AVX__
-# define libc_fetestexcept(e) \
-  ({ unsigned int mxcsr; asm volatile ("vstmxcsr %0" : "=m" (*&mxcsr));	      \
-     mxcsr & (e) & FE_ALL_EXCEPT; })
-#else
-# define libc_fetestexcept(e) \
-  ({ unsigned int mxcsr; asm volatile ("stmxcsr %0" : "=m" (*&mxcsr));	      \
+#define libc_fetestexcept(e) \
+  ({ unsigned int mxcsr; asm volatile (STMXCSR " %0" : "=m" (*&mxcsr));	      \
      mxcsr & (e) & FE_ALL_EXCEPT; })
-#endif
 #undef libc_fetestexceptf
 #define libc_fetestexceptf(e) libc_fetestexcept (e)
 // #define libc_fetestexceptl(e) fetestexcept (e)
 
 #undef libc_fesetenv
-#ifdef __AVX__
-# define libc_fesetenv(e) \
-  asm volatile ("vldmxcsr %0" : : "m" ((e)->__mxcsr))
-#else
-# define libc_fesetenv(e) \
-  asm volatile ("ldmxcsr %0" : : "m" ((e)->__mxcsr))
-#endif
+#define libc_fesetenv(e) \
+  asm volatile (LDMXCSR " %0" : : "m" ((e)->__mxcsr))
 #undef libc_fesetenvf
 #define libc_fesetenvf(e) libc_fesetenv (e)
 // #define libc_fesetenvl(e) (void) fesetenv (e)
 
 #undef libc_feupdateenv
-#ifdef __AVX__
-# define libc_feupdateenv(e) \
+#define libc_feupdateenv(e) \
   do {									      \
     unsigned int mxcsr;							      \
-    asm volatile ("vstmxcsr %0" : "=m" (*&mxcsr));			      \
-    asm volatile ("vldmxcsr %0" : : "m" ((e)->__mxcsr));		      \
+    asm volatile (STMXCSR " %0" : "=m" (*&mxcsr));			      \
+    asm volatile (LDMXCSR " %0" : : "m" ((e)->__mxcsr));		      \
     __feraiseexcept (mxcsr & FE_ALL_EXCEPT);				      \
   } while (0)
-#else
-# define libc_feupdateenv(e) \
-  do {									      \
-    unsigned int mxcsr;							      \
-    asm volatile ("stmxcsr %0" : "=m" (*&mxcsr));			      \
-    asm volatile ("ldmxcsr %0" : : "m" ((e)->__mxcsr));			      \
-    __feraiseexcept (mxcsr & FE_ALL_EXCEPT);				      \
-  } while (0)
-#endif
 #undef libc_feupdateenvf
 #define libc_feupdateenvf(e) libc_feupdateenv (e)
 // #define libc_feupdateenvl(e) (void) feupdateenv (e)