about summary refs log tree commit diff
path: root/sysdeps/i386
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2018-02-28 21:55:51 +0000
committerJoseph Myers <joseph@codesourcery.com>2018-02-28 21:55:51 +0000
commite2bcf6a8551c6b6a7eeed8f84be42b29eef4d0e2 (patch)
tree002d326503070320fc59c589ee532b21d2ee859d /sysdeps/i386
parent000f290ff179c9910f09b7f76797bdab575abb15 (diff)
downloadglibc-e2bcf6a8551c6b6a7eeed8f84be42b29eef4d0e2.tar.gz
glibc-e2bcf6a8551c6b6a7eeed8f84be42b29eef4d0e2.tar.xz
glibc-e2bcf6a8551c6b6a7eeed8f84be42b29eef4d0e2.zip
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.
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/fpu/fenv_private.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/sysdeps/i386/fpu/fenv_private.h b/sysdeps/i386/fpu/fenv_private.h
index a258f48e07..357613a500 100644
--- a/sysdeps/i386/fpu/fenv_private.h
+++ b/sysdeps/i386/fpu/fenv_private.h
@@ -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.  */