Fix i386 fenv_private.h float128 for 32-bit --with-fpmath=sse (bug 22902).

As discussed in bug 22902, the i386 fenv_private.h implementation has
problems for float128 for the case of 32-bit glibc built with libgcc
from GCC configured using --with-fpmath=sse.

The optimized floating-point state handling in fenv_private.h needs to
know which floating-point state - x87 or SSE - is used for each
floating-point type, so that only one state needs updating / testing
for libm code using that state internally.  On 32-bit x86, the x87
rounding mode is always used for float128, but the x87 exception flags
are only used when libgcc is built using x87 floating-point
arithmetic; if libgcc is built for SSE arithmetic, the SSE exception
flags are used.

The choice of arithmetic with which libgcc is built is independent of
that with which glibc is built.  Thus, since glibc cannot tell the
choice used in libgcc, the default implementations of
libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128 (which
use the <fenv.h> functions, thus using both x87 and SSE state on
processors that have both) need to be used; this patch updates the
code accordingly.

Tested for 32-bit x86; HJ reports testing in the --with-fpmath=sse
case.

	[BZ #22902]
	* sysdeps/i386/fpu/fenv_private.h [!__x86_64__]
	(libc_feholdexcept_setroundf128): New macro.
	[!__x86_64__] (libc_feupdateenv_testf128): Likewise.
This commit is contained in:
Joseph Myers 2018-02-28 21:55:51 +00:00
parent 000f290ff1
commit e2bcf6a855
2 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,10 @@
2018-02-28 Joseph Myers <joseph@codesourcery.com>
[BZ #22902]
* sysdeps/i386/fpu/fenv_private.h [!__x86_64__]
(libc_feholdexcept_setroundf128): New macro.
[!__x86_64__] (libc_feupdateenv_testf128): Likewise.
[BZ #15105]
* sysdeps/wordsize-32/strtoumax.c (strtoumax): Use
libc_hidden_def.

View File

@ -339,6 +339,12 @@ libc_feresetround_387 (fenv_t *e)
SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_sse, libc_feresetround_sse)
# define libc_feholdexcept_setroundf128 libc_feholdexcept_setround_sse
# define libc_feupdateenv_testf128 libc_feupdateenv_test_sse
#else
/* The 387 rounding mode is used by soft-fp for 32-bit, but whether
387 or SSE exceptions are used depends on whether libgcc was built
for SSE math, which is not known when glibc is being built. */
# define libc_feholdexcept_setroundf128 default_libc_feholdexcept_setround
# define libc_feupdateenv_testf128 default_libc_feupdateenv_test
#endif
/* We have support for rounding mode context. */