mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 14:00:30 +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>
|
2012-01-19 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
|
||||||
|
|
||||||
* sysdeps/powerpc/powerpc32/a2/memcpy.S: Fix for when cache line
|
* sysdeps/powerpc/powerpc32/a2/memcpy.S: Fix for when cache line
|
||||||
|
@ -21,8 +21,12 @@
|
|||||||
|
|
||||||
#ifdef __AVX__
|
#ifdef __AVX__
|
||||||
# define MOVD "vmovd"
|
# define MOVD "vmovd"
|
||||||
|
# define STMXCSR "vstmxcsr"
|
||||||
|
# define LDMXCSR "vldmxcsr"
|
||||||
#else
|
#else
|
||||||
# define MOVD "movd"
|
# define MOVD "movd"
|
||||||
|
# define STMXCSR "stmxcsr"
|
||||||
|
# define LDMXCSR "ldmxcsr"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Direct movement of float into integer register. */
|
/* Direct movement of float into integer register. */
|
||||||
@ -173,7 +177,7 @@
|
|||||||
#define libc_fegetround() \
|
#define libc_fegetround() \
|
||||||
({ \
|
({ \
|
||||||
unsigned int mxcsr; \
|
unsigned int mxcsr; \
|
||||||
asm volatile ("stmxcsr %0" : "=m" (*&mxcsr)); \
|
asm volatile (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||||
(mxcsr & 0x6000) >> 3; \
|
(mxcsr & 0x6000) >> 3; \
|
||||||
})
|
})
|
||||||
#undef libc_fegetroundf
|
#undef libc_fegetroundf
|
||||||
@ -184,106 +188,63 @@
|
|||||||
#define libc_fesetround(r) \
|
#define libc_fesetround(r) \
|
||||||
do { \
|
do { \
|
||||||
unsigned int mxcsr; \
|
unsigned int mxcsr; \
|
||||||
asm ("stmxcsr %0" : "=m" (*&mxcsr)); \
|
asm (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||||
mxcsr = (mxcsr & ~0x6000) | ((r) << 3); \
|
mxcsr = (mxcsr & ~0x6000) | ((r) << 3); \
|
||||||
asm volatile ("ldmxcsr %0" : : "m" (*&mxcsr)); \
|
asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#undef libc_fesetroundf
|
#undef libc_fesetroundf
|
||||||
#define libc_fesetroundf(r) libc_fesetround (r)
|
#define libc_fesetroundf(r) libc_fesetround (r)
|
||||||
// #define libc_fesetroundl(r) (void) fesetround (r)
|
// #define libc_fesetroundl(r) (void) fesetround (r)
|
||||||
|
|
||||||
#undef libc_feholdexcept
|
#undef libc_feholdexcept
|
||||||
#ifdef __AVX__
|
#define libc_feholdexcept(e) \
|
||||||
# define libc_feholdexcept(e) \
|
|
||||||
do { \
|
do { \
|
||||||
unsigned int mxcsr; \
|
unsigned int mxcsr; \
|
||||||
asm ("vstmxcsr %0" : "=m" (*&mxcsr)); \
|
asm (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||||
(e)->__mxcsr = mxcsr; \
|
(e)->__mxcsr = mxcsr; \
|
||||||
mxcsr = (mxcsr | 0x1f80) & ~0x3f; \
|
mxcsr = (mxcsr | 0x1f80) & ~0x3f; \
|
||||||
asm volatile ("vldmxcsr %0" : : "m" (*&mxcsr)); \
|
asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr)); \
|
||||||
} while (0)
|
} 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
|
#undef libc_feholdexceptf
|
||||||
#define libc_feholdexceptf(e) libc_feholdexcept (e)
|
#define libc_feholdexceptf(e) libc_feholdexcept (e)
|
||||||
// #define libc_feholdexceptl(e) (void) feholdexcept (e)
|
// #define libc_feholdexceptl(e) (void) feholdexcept (e)
|
||||||
|
|
||||||
#undef libc_feholdexcept_setround
|
#undef libc_feholdexcept_setround
|
||||||
#ifdef __AVX__
|
#define libc_feholdexcept_setround(e, r) \
|
||||||
# define libc_feholdexcept_setround(e, r) \
|
|
||||||
do { \
|
do { \
|
||||||
unsigned int mxcsr; \
|
unsigned int mxcsr; \
|
||||||
asm ("vstmxcsr %0" : "=m" (*&mxcsr)); \
|
asm (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||||
(e)->__mxcsr = mxcsr; \
|
(e)->__mxcsr = mxcsr; \
|
||||||
mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | ((r) << 3); \
|
mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | ((r) << 3); \
|
||||||
asm volatile ("vldmxcsr %0" : : "m" (*&mxcsr)); \
|
asm volatile (LDMXCSR " %0" : : "m" (*&mxcsr)); \
|
||||||
} while (0)
|
} 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
|
#undef libc_feholdexcept_setroundf
|
||||||
#define libc_feholdexcept_setroundf(e, r) libc_feholdexcept_setround (e, r)
|
#define libc_feholdexcept_setroundf(e, r) libc_feholdexcept_setround (e, r)
|
||||||
// #define libc_feholdexcept_setroundl(e, r) ...
|
// #define libc_feholdexcept_setroundl(e, r) ...
|
||||||
|
|
||||||
#undef libc_fetestexcept
|
#undef libc_fetestexcept
|
||||||
#ifdef __AVX__
|
#define libc_fetestexcept(e) \
|
||||||
# define libc_fetestexcept(e) \
|
({ unsigned int mxcsr; asm volatile (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||||
({ unsigned int mxcsr; asm volatile ("vstmxcsr %0" : "=m" (*&mxcsr)); \
|
|
||||||
mxcsr & (e) & FE_ALL_EXCEPT; })
|
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
|
#undef libc_fetestexceptf
|
||||||
#define libc_fetestexceptf(e) libc_fetestexcept (e)
|
#define libc_fetestexceptf(e) libc_fetestexcept (e)
|
||||||
// #define libc_fetestexceptl(e) fetestexcept (e)
|
// #define libc_fetestexceptl(e) fetestexcept (e)
|
||||||
|
|
||||||
#undef libc_fesetenv
|
#undef libc_fesetenv
|
||||||
#ifdef __AVX__
|
#define libc_fesetenv(e) \
|
||||||
# define libc_fesetenv(e) \
|
asm volatile (LDMXCSR " %0" : : "m" ((e)->__mxcsr))
|
||||||
asm volatile ("vldmxcsr %0" : : "m" ((e)->__mxcsr))
|
|
||||||
#else
|
|
||||||
# define libc_fesetenv(e) \
|
|
||||||
asm volatile ("ldmxcsr %0" : : "m" ((e)->__mxcsr))
|
|
||||||
#endif
|
|
||||||
#undef libc_fesetenvf
|
#undef libc_fesetenvf
|
||||||
#define libc_fesetenvf(e) libc_fesetenv (e)
|
#define libc_fesetenvf(e) libc_fesetenv (e)
|
||||||
// #define libc_fesetenvl(e) (void) fesetenv (e)
|
// #define libc_fesetenvl(e) (void) fesetenv (e)
|
||||||
|
|
||||||
#undef libc_feupdateenv
|
#undef libc_feupdateenv
|
||||||
#ifdef __AVX__
|
#define libc_feupdateenv(e) \
|
||||||
# define libc_feupdateenv(e) \
|
|
||||||
do { \
|
do { \
|
||||||
unsigned int mxcsr; \
|
unsigned int mxcsr; \
|
||||||
asm volatile ("vstmxcsr %0" : "=m" (*&mxcsr)); \
|
asm volatile (STMXCSR " %0" : "=m" (*&mxcsr)); \
|
||||||
asm volatile ("vldmxcsr %0" : : "m" ((e)->__mxcsr)); \
|
asm volatile (LDMXCSR " %0" : : "m" ((e)->__mxcsr)); \
|
||||||
__feraiseexcept (mxcsr & FE_ALL_EXCEPT); \
|
__feraiseexcept (mxcsr & FE_ALL_EXCEPT); \
|
||||||
} while (0)
|
} 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
|
#undef libc_feupdateenvf
|
||||||
#define libc_feupdateenvf(e) libc_feupdateenv (e)
|
#define libc_feupdateenvf(e) libc_feupdateenv (e)
|
||||||
// #define libc_feupdateenvl(e) (void) feupdateenv (e)
|
// #define libc_feupdateenvl(e) (void) feupdateenv (e)
|
||||||
|
Loading…
Reference in New Issue
Block a user