|
|
a2cf7d |
commit e68b1151f7460d5fa88c3a567c13f66052da79a7
|
|
|
a2cf7d |
Author: Paul A. Clarke <pc@us.ibm.com>
|
|
|
a2cf7d |
Date: Thu Sep 19 11:39:44 2019 -0500
|
|
|
a2cf7d |
|
|
|
a2cf7d |
[powerpc] __fesetround_inline optimizations
|
|
|
a2cf7d |
|
|
|
a2cf7d |
On POWER9, use more efficient means to update the 2-bit rounding mode
|
|
|
a2cf7d |
via the 'mffscrn' instruction (instead of two 'mtfsb0/1' instructions
|
|
|
a2cf7d |
or one 'mtfsfi' instruction that modifies 4 bits).
|
|
|
a2cf7d |
|
|
|
a2cf7d |
Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com>
|
|
|
a2cf7d |
Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
|
|
|
a2cf7d |
|
|
|
a2cf7d |
diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
a2cf7d |
index 86ae7fda016abd8b..c3f541c08440b20e 100644
|
|
|
a2cf7d |
--- a/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
a2cf7d |
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
|
|
|
a2cf7d |
@@ -149,7 +149,12 @@ typedef union
|
|
|
a2cf7d |
static inline int
|
|
|
a2cf7d |
__fesetround_inline (int round)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
- if ((unsigned int) round < 2)
|
|
|
a2cf7d |
+#ifdef _ARCH_PWR9
|
|
|
a2cf7d |
+ __fe_mffscrn (round);
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+ if (__glibc_likely (GLRO(dl_hwcap2) & PPC_FEATURE2_ARCH_3_00))
|
|
|
a2cf7d |
+ __fe_mffscrn (round);
|
|
|
a2cf7d |
+ else if ((unsigned int) round < 2)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
asm volatile ("mtfsb0 30");
|
|
|
a2cf7d |
if ((unsigned int) round == 0)
|
|
|
a2cf7d |
@@ -165,7 +170,7 @@ __fesetround_inline (int round)
|
|
|
a2cf7d |
else
|
|
|
a2cf7d |
asm volatile ("mtfsb1 31");
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
-
|
|
|
a2cf7d |
+#endif
|
|
|
a2cf7d |
return 0;
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
|
|
|
a2cf7d |
@@ -174,7 +179,14 @@ __fesetround_inline (int round)
|
|
|
a2cf7d |
static inline void
|
|
|
a2cf7d |
__fesetround_inline_nocheck (const int round)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
- asm volatile ("mtfsfi 7,%0" : : "i" (round));
|
|
|
a2cf7d |
+#ifdef _ARCH_PWR9
|
|
|
a2cf7d |
+ __fe_mffscrn (round);
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+ if (__glibc_likely (GLRO(dl_hwcap2) & PPC_FEATURE2_ARCH_3_00))
|
|
|
a2cf7d |
+ __fe_mffscrn (round);
|
|
|
a2cf7d |
+ else
|
|
|
a2cf7d |
+ asm volatile ("mtfsfi 7,%0" : : "i" (round));
|
|
|
a2cf7d |
+#endif
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
|
|
|
a2cf7d |
#define FPSCR_MASK(bit) (1 << (31 - (bit)))
|