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