glibc/sysdeps/powerpc/fpu
Paul Clarke 346729f66b powerpc: fix check-before-set in SET_RESTORE_ROUND
A performance regression was introduced by commit
84d74e427a "powerpc: Cleanup fenv_private.h".

In the powerpc implementation of SET_RESTORE_ROUND, there is the
following code in the "SET" function (slightly simplified):
--
  old.fenv = fegetenv_register ();

  new.l = (old.l & _FPU_MASK_TRAPS_RN) | r; (1)

  if (new.l != old.l)                       (2)
    {
      if ((old.l & _FPU_ALL_TRAPS) != 0)
        (void) __fe_mask_env ();
      fesetenv_register (new.fenv);         (3)
--

Line (1) sets the value of "new" to the current value of FPSCR,
but masks off summary bits, exceptions, non-IEEE mode, and
rounding mode, then ORs in the new rounding mode.

Line (2) compares this new value to the current value in order to
avoid setting a new value in the FPSCR (line (3)) unless something
significant has changed (exception enables or rounding mode).

The summary bits are not germane to the comparison, but are cleared
in "new" and preserved in "old", resulting in false negative
comparisons, and unnecessarily setting the FPSCR in those cases
with associated negative performance impacts.

The solution is to treat the summaries identically for "new" and "old":
- save them in SET
- leave them alone otherwise
- restore the saved values in RESTORE

Also minor changes:
- expand _FPU_MASK_RN to 64bit hex, to match other MASKs
- treat bit 52 (left-to-right) as reserved (since it is)

	* sysdeps/powerpc/fpu/fenv_private.h (_FPU_MASK_TRAPS_RN):
	(_FPU_MASK_FRAC_INEX_RET_CC): Fix masks to more properly handle
	summary bits.
	(_FPU_MASK_RN): Expand _FPU_MASK_RN to 64bit hex.
	(_FPU_MASK_NOT_RN_NI): Treat bit 52 (left-to-right) as reserved.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
2017-10-18 12:08:28 -02:00
..
e_hypot.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_hypotf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_rem_pio2f.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_sqrt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_sqrtf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fclrexcpt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fe_mask.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fe_nomask.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fedisblxcpt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
feenablxcpt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fegetenv.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fegetexcept.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fegetmode.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fegetround.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
feholdexcpt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fenv_const.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fenv_libc.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fenv_private.h powerpc: fix check-before-set in SET_RESTORE_ROUND 2017-10-18 12:08:28 -02:00
fesetenv.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fesetexcept.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fesetmode.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fesetround.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
feupdateenv.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fgetexcptflg.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fix-fp-int-compare-invalid.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fraiseexcpt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fsetexcptflg.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
ftestexcept.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
k_cosf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
k_rem_pio2f.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
k_sinf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
libm-test-ulps powerpc: Regenerate ULPs for expf() and exp2f() 2017-09-26 16:13:33 -03:00
libm-test-ulps-name Do not hardcode platform names in manual/libm-err-tab.pl (bug 14139). 2016-11-04 16:49:06 +00:00
Makefile Link extra-libs consistently with libc and ld.so. 2013-05-31 16:16:33 +00:00
math_ldbl.h Allow direct use of math_ldbl.h in testsuite. 2017-02-25 10:40:48 -05:00
math_private.h powerpc: Avoid putting floating point values in memory [BZ #22189] 2017-10-13 15:44:39 -03:00
s_cosf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_fabs.S Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_fabsf.S
s_float_bitwise.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_fma.S PowerPC64 ENTRY_TOCLESS 2017-06-14 10:45:50 +09:30
s_fmaf.S PowerPC64 ENTRY_TOCLESS 2017-06-14 10:45:50 +09:30
s_isnan.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_isnanf.S
s_lrintf.S
s_rint.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_rintf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_sinf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
t_sqrt.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
tst-setcontext-fpscr.c Miscellaneous low-risk changes preparing for _ISOMAC testsuite. 2017-03-01 20:32:50 -05:00