mirror of git://sourceware.org/git/glibc.git
Optimize fesetenv
Improve fesetenv to use an optimized implementation similar to feupdateenv. 2014-06-24 Wilco <wdijkstr@arm.com> * sysdeps/arm/fesetenv.c (fesetenv): Optimize implementation.
This commit is contained in:
parent
b5570d92d6
commit
b8c005732e
|
@ -1,3 +1,7 @@
|
||||||
|
2014-06-24 Wilco <wdijkstr@arm.com>
|
||||||
|
|
||||||
|
* sysdeps/arm/fesetenv.c (fesetenv): Optimize implementation.
|
||||||
|
|
||||||
2014-06-24 Wilco <wdijkstr@arm.com>
|
2014-06-24 Wilco <wdijkstr@arm.com>
|
||||||
|
|
||||||
* sysdeps/arm/fpu_control.h (_FPU_MASK_RM): Define.
|
* sysdeps/arm/fpu_control.h (_FPU_MASK_RM): Define.
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
#include <fpu_control.h>
|
|
||||||
#include <arm-features.h>
|
#include <arm-features.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fesetenv (const fenv_t *envp)
|
fesetenv (const fenv_t *envp)
|
||||||
{
|
{
|
||||||
fpu_control_t fpscr;
|
fpu_control_t fpscr, new_fpscr, updated_fpscr;
|
||||||
|
|
||||||
/* Fail if a VFP unit isn't present. */
|
/* Fail if a VFP unit isn't present. */
|
||||||
if (!ARM_HAVE_VFP)
|
if (!ARM_HAVE_VFP)
|
||||||
|
@ -32,25 +31,31 @@ fesetenv (const fenv_t *envp)
|
||||||
|
|
||||||
_FPU_GETCW (fpscr);
|
_FPU_GETCW (fpscr);
|
||||||
|
|
||||||
/* Preserve the reserved FPSCR flags. */
|
if ((envp != FE_DFL_ENV) && (envp != FE_NOMASK_ENV))
|
||||||
fpscr &= _FPU_RESERVED;
|
|
||||||
|
|
||||||
if (envp == FE_DFL_ENV)
|
|
||||||
fpscr |= _FPU_DEFAULT;
|
|
||||||
else if (envp == FE_NOMASK_ENV)
|
|
||||||
fpscr |= _FPU_IEEE;
|
|
||||||
else
|
|
||||||
fpscr |= envp->__cw & ~_FPU_RESERVED;
|
|
||||||
|
|
||||||
_FPU_SETCW (fpscr);
|
|
||||||
|
|
||||||
if (envp == FE_NOMASK_ENV)
|
|
||||||
{
|
{
|
||||||
|
/* The new FPSCR is valid, so don't merge the reserved flags. */
|
||||||
|
new_fpscr = envp->__cw;
|
||||||
|
|
||||||
|
/* Write new FPSCR if different (ignoring NZCV flags). */
|
||||||
|
if (((fpscr ^ new_fpscr) & ~_FPU_MASK_NZCV) != 0)
|
||||||
|
_FPU_SETCW (new_fpscr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Preserve the reserved FPSCR flags. */
|
||||||
|
new_fpscr = fpscr & _FPU_RESERVED;
|
||||||
|
new_fpscr |= (envp == FE_DFL_ENV) ? _FPU_DEFAULT : _FPU_IEEE;
|
||||||
|
|
||||||
|
if (((new_fpscr ^ fpscr) & ~_FPU_MASK_NZCV) != 0)
|
||||||
|
{
|
||||||
|
_FPU_SETCW (new_fpscr);
|
||||||
|
|
||||||
/* Not all VFP architectures support trapping exceptions, so
|
/* Not all VFP architectures support trapping exceptions, so
|
||||||
test whether the relevant bits were set and fail if not. */
|
test whether the relevant bits were set and fail if not. */
|
||||||
_FPU_GETCW (fpscr);
|
_FPU_GETCW (updated_fpscr);
|
||||||
if ((fpscr & _FPU_IEEE) != _FPU_IEEE)
|
|
||||||
return 1;
|
return new_fpscr & ~updated_fpscr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue