mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
Simplify use of AVX instructions in internal math macros
This commit is contained in:
parent
d73f93a461
commit
73139a7628
@ -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
|
||||
|
@ -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) \
|
||||
#define libc_feholdexcept(e) \
|
||||
do { \
|
||||
unsigned int mxcsr; \
|
||||
asm ("vstmxcsr %0" : "=m" (*&mxcsr)); \
|
||||
asm (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||
(e)->__mxcsr = mxcsr; \
|
||||
mxcsr = (mxcsr | 0x1f80) & ~0x3f; \
|
||||
asm volatile ("vldmxcsr %0" : : "m" (*&mxcsr)); \
|
||||
asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr)); \
|
||||
} while (0)
|
||||
#else
|
||||
# define libc_feholdexcept(e) \
|
||||
do { \
|
||||
unsigned int mxcsr; \
|
||||
asm ("stmxcsr %0" : "=m" (*&mxcsr)); \
|
||||
(e)->__mxcsr = mxcsr; \
|
||||
mxcsr = (mxcsr | 0x1f80) & ~0x3f; \
|
||||
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) \
|
||||
#define libc_feholdexcept_setround(e, r) \
|
||||
do { \
|
||||
unsigned int mxcsr; \
|
||||
asm ("vstmxcsr %0" : "=m" (*&mxcsr)); \
|
||||
asm (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||
(e)->__mxcsr = mxcsr; \
|
||||
mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | ((r) << 3); \
|
||||
asm volatile ("vldmxcsr %0" : : "m" (*&mxcsr)); \
|
||||
asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr)); \
|
||||
} while (0)
|
||||
#else
|
||||
# define libc_feholdexcept_setround(e, r) \
|
||||
do { \
|
||||
unsigned int mxcsr; \
|
||||
asm ("stmxcsr %0" : "=m" (*&mxcsr)); \
|
||||
(e)->__mxcsr = mxcsr; \
|
||||
mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | ((r) << 3); \
|
||||
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)); \
|
||||
#define libc_fetestexcept(e) \
|
||||
({ unsigned int mxcsr; asm volatile (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||
mxcsr & (e) & FE_ALL_EXCEPT; })
|
||||
#else
|
||||
# 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)
|
||||
|
Loading…
Reference in New Issue
Block a user