arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1302086-5.patch

147e83
commit e5e0d9a4f632735cf3bb440eecb5caee5eea44c1
147e83
Author: Ian Bolton <ian.bolton@arm.com>
147e83
Date:   Thu Apr 24 07:15:33 2014 +0100
147e83
147e83
    [AArch64] Suppress unnecessary FPSR and FPCR writes.
147e83
147e83
diff --git a/ports/sysdeps/aarch64/fpu/fclrexcpt.c b/ports/sysdeps/aarch64/fpu/fclrexcpt.c
147e83
index 531269f..b24f0ff 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/fclrexcpt.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/fclrexcpt.c
147e83
@@ -23,13 +23,15 @@ int
147e83
 feclearexcept (int excepts)
147e83
 {
147e83
   fpu_fpsr_t fpsr;
147e83
+  fpu_fpsr_t fpsr_new;
147e83
 
147e83
   excepts &= FE_ALL_EXCEPT;
147e83
 
147e83
   _FPU_GETFPSR (fpsr);
147e83
-  fpsr = (fpsr & ~FE_ALL_EXCEPT) | (fpsr & FE_ALL_EXCEPT & ~excepts);
147e83
+  fpsr_new = (fpsr & ~FE_ALL_EXCEPT) | (fpsr & FE_ALL_EXCEPT & ~excepts);
147e83
 
147e83
-  _FPU_SETFPSR (fpsr);
147e83
+  if (fpsr != fpsr_new)
147e83
+    _FPU_SETFPSR (fpsr_new);
147e83
 
147e83
   return 0;
147e83
 }
147e83
diff --git a/ports/sysdeps/aarch64/fpu/fedisblxcpt.c b/ports/sysdeps/aarch64/fpu/fedisblxcpt.c
147e83
index 719d52f..c43335c 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/fedisblxcpt.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/fedisblxcpt.c
147e83
@@ -23,6 +23,7 @@ int
147e83
 fedisableexcept (int excepts)
147e83
 {
147e83
   fpu_control_t fpcr;
147e83
+  fpu_control_t fpcr_new;
147e83
   int original_excepts;
147e83
 
147e83
   _FPU_GETCW (fpcr);
147e83
@@ -31,9 +32,10 @@ fedisableexcept (int excepts)
147e83
 
147e83
   excepts &= FE_ALL_EXCEPT;
147e83
 
147e83
-  fpcr &= ~(excepts << FE_EXCEPT_SHIFT);
147e83
+  fpcr_new = fpcr & ~(excepts << FE_EXCEPT_SHIFT);
147e83
 
147e83
-  _FPU_SETCW (fpcr);
147e83
+  if (fpcr != fpcr_new)
147e83
+    _FPU_SETCW (fpcr_new);
147e83
 
147e83
   return original_excepts;
147e83
 }
147e83
diff --git a/ports/sysdeps/aarch64/fpu/feenablxcpt.c b/ports/sysdeps/aarch64/fpu/feenablxcpt.c
147e83
index 07a4bbb..70e413c 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/feenablxcpt.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/feenablxcpt.c
147e83
@@ -23,6 +23,7 @@ int
147e83
 feenableexcept (int excepts)
147e83
 {
147e83
   fpu_control_t fpcr;
147e83
+  fpu_control_t fpcr_new;
147e83
   int original_excepts;
147e83
 
147e83
   _FPU_GETCW (fpcr);
147e83
@@ -31,9 +32,10 @@ feenableexcept (int excepts)
147e83
 
147e83
   excepts &= FE_ALL_EXCEPT;
147e83
 
147e83
-  fpcr |= (excepts << FE_EXCEPT_SHIFT);
147e83
+  fpcr_new = fpcr | (excepts << FE_EXCEPT_SHIFT);
147e83
 
147e83
-  _FPU_SETCW (fpcr);
147e83
+  if (fpcr != fpcr_new)
147e83
+    _FPU_SETCW (fpcr_new);
147e83
 
147e83
   /* Trapping exceptions are optional in AArch64 the relevant enable
147e83
      bits in FPCR are RES0 hence the absence of support can be
147e83
diff --git a/ports/sysdeps/aarch64/fpu/feholdexcpt.c b/ports/sysdeps/aarch64/fpu/feholdexcpt.c
147e83
index 0514ac1..973ba4a 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/feholdexcpt.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/feholdexcpt.c
147e83
@@ -22,8 +22,10 @@
147e83
 int
147e83
 feholdexcept (fenv_t *envp)
147e83
 {
147e83
-  fpu_fpsr_t fpsr;
147e83
   fpu_control_t fpcr;
147e83
+  fpu_control_t fpcr_new;
147e83
+  fpu_fpsr_t fpsr;
147e83
+  fpu_fpsr_t fpsr_new;
147e83
 
147e83
   _FPU_GETCW (fpcr);
147e83
   envp->__fpcr = fpcr;
147e83
@@ -32,14 +34,16 @@ feholdexcept (fenv_t *envp)
147e83
   envp->__fpsr = fpsr;
147e83
 
147e83
   /* Now set all exceptions to non-stop.  */
147e83
-  fpcr &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
147e83
+  fpcr_new = fpcr & ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
147e83
 
147e83
   /* And clear all exception flags.  */
147e83
-  fpsr &= ~FE_ALL_EXCEPT;
147e83
+  fpsr_new = fpsr & ~FE_ALL_EXCEPT;
147e83
 
147e83
-  _FPU_SETFPSR (fpsr);
147e83
+  if (fpsr != fpsr_new)
147e83
+    _FPU_SETFPSR (fpsr_new);
147e83
 
147e83
-  _FPU_SETCW (fpcr);
147e83
+  if (fpcr != fpcr_new)
147e83
+    _FPU_SETCW (fpcr_new);
147e83
 
147e83
   return 0;
147e83
 }
147e83
diff --git a/ports/sysdeps/aarch64/fpu/fesetenv.c b/ports/sysdeps/aarch64/fpu/fesetenv.c
147e83
index a2434e3..30193e9 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/fesetenv.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/fesetenv.c
147e83
@@ -23,34 +23,38 @@ int
147e83
 fesetenv (const fenv_t *envp)
147e83
 {
147e83
   fpu_control_t fpcr;
147e83
-  fpu_fpsr_t fpsr;
147e83
+  fpu_control_t fpcr_new;
147e83
   fpu_control_t updated_fpcr;
147e83
+  fpu_fpsr_t fpsr;
147e83
+  fpu_fpsr_t fpsr_new;
147e83
 
147e83
   _FPU_GETCW (fpcr);
147e83
   _FPU_GETFPSR (fpsr);
147e83
 
147e83
-  fpcr &= _FPU_RESERVED;
147e83
-  fpsr &= _FPU_FPSR_RESERVED;
147e83
+  fpcr_new = fpcr & _FPU_RESERVED;
147e83
+  fpsr_new = fpsr & _FPU_FPSR_RESERVED;
147e83
 
147e83
   if (envp == FE_DFL_ENV)
147e83
     {
147e83
-      fpcr |= _FPU_DEFAULT;
147e83
-      fpsr |= _FPU_FPSR_DEFAULT;
147e83
+      fpcr_new |= _FPU_DEFAULT;
147e83
+      fpsr_new |= _FPU_FPSR_DEFAULT;
147e83
     }
147e83
   else if (envp == FE_NOMASK_ENV)
147e83
     {
147e83
-      fpcr |= _FPU_FPCR_IEEE;
147e83
-      fpsr |= _FPU_FPSR_IEEE;
147e83
+      fpcr_new |= _FPU_FPCR_IEEE;
147e83
+      fpsr_new |= _FPU_FPSR_IEEE;
147e83
     }
147e83
   else
147e83
     {
147e83
-      fpcr |= envp->__fpcr & ~_FPU_RESERVED;
147e83
-      fpsr |= envp->__fpsr & ~_FPU_FPSR_RESERVED;
147e83
+      fpcr_new |= envp->__fpcr & ~_FPU_RESERVED;
147e83
+      fpsr_new |= envp->__fpsr & ~_FPU_FPSR_RESERVED;
147e83
     }
147e83
 
147e83
-  _FPU_SETFPSR (fpsr);
147e83
+  if (fpsr != fpsr_new)
147e83
+    _FPU_SETFPSR (fpsr_new);
147e83
 
147e83
-  _FPU_SETCW (fpcr);
147e83
+  if (fpcr != fpcr_new)
147e83
+    _FPU_SETCW (fpcr_new);
147e83
 
147e83
   /* Trapping exceptions are optional in AArch64 the relevant enable
147e83
      bits in FPCR are RES0 hence the absence of support can be
147e83
@@ -58,7 +62,7 @@ fesetenv (const fenv_t *envp)
147e83
      value.  */
147e83
 
147e83
   _FPU_GETCW (updated_fpcr);
147e83
-  if ((updated_fpcr & fpcr) != fpcr)
147e83
+  if ((updated_fpcr & fpcr_new) != fpcr_new)
147e83
     return 1;
147e83
 
147e83
   return 0;
147e83
diff --git a/ports/sysdeps/aarch64/fpu/fesetround.c b/ports/sysdeps/aarch64/fpu/fesetround.c
147e83
index 40a05f6..225096a 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/fesetround.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/fesetround.c
147e83
@@ -23,6 +23,7 @@ int
147e83
 fesetround (int round)
147e83
 {
147e83
   fpu_control_t fpcr;
147e83
+  fpu_control_t fpcr_new;
147e83
 
147e83
   switch (round)
147e83
     {
147e83
@@ -31,9 +32,10 @@ fesetround (int round)
147e83
     case FE_DOWNWARD:
147e83
     case FE_TOWARDZERO:
147e83
       _FPU_GETCW (fpcr);
147e83
-      fpcr = (fpcr & ~FE_TOWARDZERO) | round;
147e83
+      fpcr_new = (fpcr & ~FE_TOWARDZERO) | round;
147e83
 
147e83
-      _FPU_SETCW (fpcr);
147e83
+      if (fpcr != fpcr_new)
147e83
+	_FPU_SETCW (fpcr_new);
147e83
       return 0;
147e83
 
147e83
     default:
147e83
diff --git a/ports/sysdeps/aarch64/fpu/fsetexcptflg.c b/ports/sysdeps/aarch64/fpu/fsetexcptflg.c
147e83
index 49cd1e4..60bb1c9 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/fsetexcptflg.c
147e83
+++ b/ports/sysdeps/aarch64/fpu/fsetexcptflg.c
147e83
@@ -24,16 +24,18 @@ int
147e83
 fesetexceptflag (const fexcept_t *flagp, int excepts)
147e83
 {
147e83
   fpu_fpsr_t fpsr;
147e83
+  fpu_fpsr_t fpsr_new;
147e83
 
147e83
   /* Get the current environment.  */
147e83
   _FPU_GETFPSR (fpsr);
147e83
 
147e83
   /* Set the desired exception mask.  */
147e83
-  fpsr &= ~(excepts & FE_ALL_EXCEPT);
147e83
-  fpsr |= (*flagp & excepts & FE_ALL_EXCEPT);
147e83
+  fpsr_new = fpsr & ~(excepts & FE_ALL_EXCEPT);
147e83
+  fpsr_new |= (*flagp & excepts & FE_ALL_EXCEPT);
147e83
 
147e83
   /* Save state back to the FPU.  */
147e83
-  _FPU_SETFPSR (fpsr);
147e83
+  if (fpsr != fpsr_new)
147e83
+    _FPU_SETFPSR (fpsr_new);
147e83
 
147e83
   return 0;
147e83
 }