|
|
7c0489 |
commit 0b3c9e57a41d9f7c26fb6aa45b99f671bef9c7e0
|
|
|
7c0489 |
Author: Paul A. Clarke <pc@us.ibm.com>
|
|
|
7c0489 |
Date: Tue Aug 20 15:57:35 2019 -0500
|
|
|
7c0489 |
|
|
|
7c0489 |
[powerpc] fegetenv_status: simplify instruction generation
|
|
|
7c0489 |
|
|
|
7c0489 |
fegetenv_status() wants to use the lighter weight instruction 'mffsl'
|
|
|
7c0489 |
for reading the Floating-Point Status and Control Register (FPSCR).
|
|
|
7c0489 |
It currently will use it directly if compiled '-mcpu=power9', and will
|
|
|
7c0489 |
perform a runtime check (cpu_supports("arch_3_00")) otherwise.
|
|
|
7c0489 |
|
|
|
7c0489 |
Nicely, it turns out that the 'mffsl' instruction will decode to
|
|
|
7c0489 |
'mffs' on architectures older than "arch_3_00" because the additional
|
|
|
7c0489 |
bits set for 'mffsl' are "don't care" for 'mffs'. 'mffs' is a superset
|
|
|
7c0489 |
of 'mffsl'.
|
|
|
7c0489 |
|
|
|
7c0489 |
So, just generate 'mffsl'.
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
7c0489 |
index b244770d115ea7bb..e8d40ea256b6c5bc 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
7c0489 |
@@ -36,9 +36,12 @@ extern const fenv_t *__fe_mask_env (void) attribute_hidden;
|
|
|
7c0489 |
({ fenv_t env; asm volatile ("mffs %0" : "=f" (env)); env; })
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Equivalent to fegetenv_register, but only returns bits for
|
|
|
7c0489 |
- status, exception enables, and mode. */
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-#define fegetenv_status_ISA300() \
|
|
|
7c0489 |
+ status, exception enables, and mode.
|
|
|
7c0489 |
+ Nicely, it turns out that the 'mffsl' instruction will decode to
|
|
|
7c0489 |
+ 'mffs' on architectures older than "power9" because the additional
|
|
|
7c0489 |
+ bits set for 'mffsl' are "don't care" for 'mffs'. 'mffs' is a superset
|
|
|
7c0489 |
+ of 'mffsl'. */
|
|
|
7c0489 |
+#define fegetenv_status() \
|
|
|
7c0489 |
({register double __fr; \
|
|
|
7c0489 |
__asm__ __volatile__ ( \
|
|
|
7c0489 |
".machine push; .machine \"power9\"; mffsl %0; .machine pop" \
|
|
|
7c0489 |
@@ -46,18 +49,6 @@ extern const fenv_t *__fe_mask_env (void) attribute_hidden;
|
|
|
7c0489 |
__fr; \
|
|
|
7c0489 |
})
|
|
|
7c0489 |
|
|
|
7c0489 |
-#ifdef _ARCH_PWR9
|
|
|
7c0489 |
-# define fegetenv_status() fegetenv_status_ISA300()
|
|
|
7c0489 |
-#elif defined __BUILTIN_CPU_SUPPORTS__
|
|
|
7c0489 |
-# define fegetenv_status() \
|
|
|
7c0489 |
- (__glibc_likely (__builtin_cpu_supports ("arch_3_00")) \
|
|
|
7c0489 |
- ? fegetenv_status_ISA300() \
|
|
|
7c0489 |
- : fegetenv_register() \
|
|
|
7c0489 |
- )
|
|
|
7c0489 |
-#else
|
|
|
7c0489 |
-# define fegetenv_status() fegetenv_register ()
|
|
|
7c0489 |
-#endif
|
|
|
7c0489 |
-
|
|
|
7c0489 |
/* Equivalent to fesetenv, but takes a fenv_t instead of a pointer. */
|
|
|
7c0489 |
#define fesetenv_register(env) \
|
|
|
7c0489 |
do { \
|