|
|
7c0489 |
commit fec2bd2c2d31bc731cf61623e150d047746954bd
|
|
|
7c0489 |
Author: Paul A. Clarke <pc@us.ibm.com>
|
|
|
7c0489 |
Date: Tue Aug 6 00:13:45 2019 -0400
|
|
|
7c0489 |
|
|
|
7c0489 |
[powerpc] fesetenv: optimize FPSCR access
|
|
|
7c0489 |
|
|
|
7c0489 |
fesetenv() reads the current value of the Floating-Point Status and Control
|
|
|
7c0489 |
Register (FPSCR) to determine the difference between the current state of
|
|
|
7c0489 |
exception enables and the newly requested state. All of these bits are also
|
|
|
7c0489 |
returned by the lighter weight 'mffsl' instruction used by fegetenv_status().
|
|
|
7c0489 |
Use that instead.
|
|
|
7c0489 |
|
|
|
7c0489 |
Also, remove a local macro _FPU_MASK_ALL in favor of a common macro,
|
|
|
7c0489 |
FPU_ENABLES_MASK from fenv_libc.h.
|
|
|
7c0489 |
|
|
|
7c0489 |
Finally, use a local variable ('new') in favor of a pointer dereference
|
|
|
7c0489 |
('*envp').
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/powerpc/fpu/fesetenv.c b/sysdeps/powerpc/fpu/fesetenv.c
|
|
|
7c0489 |
index ad9fda15b12f15e3..ac927c8f3ada40b4 100644
|
|
|
7c0489 |
--- a/sysdeps/powerpc/fpu/fesetenv.c
|
|
|
7c0489 |
+++ b/sysdeps/powerpc/fpu/fesetenv.c
|
|
|
7c0489 |
@@ -19,8 +19,6 @@
|
|
|
7c0489 |
#include <fenv_libc.h>
|
|
|
7c0489 |
#include <fpu_control.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
-#define _FPU_MASK_ALL (_FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM | _FPU_MASK_XM | _FPU_MASK_IM)
|
|
|
7c0489 |
-
|
|
|
7c0489 |
int
|
|
|
7c0489 |
__fesetenv (const fenv_t *envp)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
@@ -28,25 +26,23 @@ __fesetenv (const fenv_t *envp)
|
|
|
7c0489 |
|
|
|
7c0489 |
/* get the currently set exceptions. */
|
|
|
7c0489 |
new.fenv = *envp;
|
|
|
7c0489 |
- old.fenv = fegetenv_register ();
|
|
|
7c0489 |
- if (old.l == new.l)
|
|
|
7c0489 |
- return 0;
|
|
|
7c0489 |
+ old.fenv = fegetenv_status ();
|
|
|
7c0489 |
|
|
|
7c0489 |
/* If the old env has no enabled exceptions and the new env has any enabled
|
|
|
7c0489 |
exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put the
|
|
|
7c0489 |
hardware into "precise mode" and may cause the FPU to run slower on some
|
|
|
7c0489 |
hardware. */
|
|
|
7c0489 |
- if ((old.l & _FPU_MASK_ALL) == 0 && (new.l & _FPU_MASK_ALL) != 0)
|
|
|
7c0489 |
+ if ((old.l & FPSCR_ENABLES_MASK) == 0 && (new.l & FPSCR_ENABLES_MASK) != 0)
|
|
|
7c0489 |
(void) __fe_nomask_env_priv ();
|
|
|
7c0489 |
|
|
|
7c0489 |
/* If the old env had any enabled exceptions and the new env has no enabled
|
|
|
7c0489 |
exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
|
|
|
7c0489 |
FPU to run faster because it always takes the default action and can not
|
|
|
7c0489 |
generate SIGFPE. */
|
|
|
7c0489 |
- if ((old.l & _FPU_MASK_ALL) != 0 && (new.l & _FPU_MASK_ALL) == 0)
|
|
|
7c0489 |
+ if ((old.l & FPSCR_ENABLES_MASK) != 0 && (new.l & FPSCR_ENABLES_MASK) == 0)
|
|
|
7c0489 |
(void)__fe_mask_env ();
|
|
|
7c0489 |
|
|
|
7c0489 |
- fesetenv_register (*envp);
|
|
|
7c0489 |
+ fesetenv_register (new.fenv);
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Success. */
|
|
|
7c0489 |
return 0;
|