about summary refs log tree commit diff
path: root/sysdeps/arm/setfpucw.c
diff options
context:
space:
mode:
authorWilco <wdijkstr@arm.com>2014-06-24 12:04:27 +0000
committerWilco <wdijkstr@arm.com>2014-06-24 12:04:27 +0000
commit001f7b773c637560ecfa686452a5e68d60d07db3 (patch)
tree08bd670c6b892304a287c56f6cbeb00e92276567 /sysdeps/arm/setfpucw.c
parent4841e6a6c2fa691201fb52dfaf6b6a8920229bac (diff)
downloadglibc-001f7b773c637560ecfa686452a5e68d60d07db3.tar.gz
glibc-001f7b773c637560ecfa686452a5e68d60d07db3.tar.xz
glibc-001f7b773c637560ecfa686452a5e68d60d07db3.zip
Speed up the ARM fenv implementation by avoiding unnecessary FPSCR
writes if the FPSCR remains unchanged.

2014-06-24  Wilco  <wdijkstr@arm.com>

	* sysdeps/arm/fclrexcpt.c (feclearexcept):
	Optimize to avoid unnecessary FPSCR writes.
	* sysdeps/arm/fedisblxcpt.c (fedisableexcept): Likewise.
	* sysdeps/arm/feenablxcpt.c (feenableexcept): Likewise.
	* sysdeps/arm/fsetexcptflg.c (fesetexceptflag): Likewise.
	* sysdeps/arm/setfpucw.c (__setfpucw): Likewise.
Diffstat (limited to 'sysdeps/arm/setfpucw.c')
-rw-r--r--sysdeps/arm/setfpucw.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sysdeps/arm/setfpucw.c b/sysdeps/arm/setfpucw.c
index 7416377f9e..259b020f81 100644
--- a/sysdeps/arm/setfpucw.c
+++ b/sysdeps/arm/setfpucw.c
@@ -24,19 +24,20 @@
 void
 __setfpucw (fpu_control_t set)
 {
-  fpu_control_t fpscr;
+  fpu_control_t fpscr, new_fpscr;
 
   /* Do nothing if a VFP unit isn't present.  */
   if (!ARM_HAVE_VFP)
     return;
 
-  /* Fetch the current control word.  */
   _FPU_GETCW (fpscr);
 
   /* Preserve the reserved bits, and set the rest as the user
      specified (or the default, if the user gave zero).  */
-  fpscr &= _FPU_RESERVED;
-  fpscr |= set & ~_FPU_RESERVED;
+  new_fpscr = fpscr & _FPU_RESERVED;
+  new_fpscr |= set & ~_FPU_RESERVED;
 
-  _FPU_SETCW (fpscr);
+  /* Write FPSCR if changed.  */
+  if (new_fpscr != fpscr)
+    _FPU_SETCW (fpscr);
 }