From 001f7b773c637560ecfa686452a5e68d60d07db3 Mon Sep 17 00:00:00 2001 From: Wilco Date: Tue, 24 Jun 2014 12:04:27 +0000 Subject: Speed up the ARM fenv implementation by avoiding unnecessary FPSCR writes if the FPSCR remains unchanged. 2014-06-24 Wilco * 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. --- sysdeps/arm/setfpucw.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sysdeps/arm/setfpucw.c') 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); } -- cgit 1.4.1