Update x86 fix-fp-int-compare-invalid.h for GCC 8 [committed]

Message ID alpine.DEB.2.20.1710240033380.19664@digraph.polyomino.org.uk
State Committed
Headers

Commit Message

Joseph Myers Oct. 24, 2017, 12:33 a.m. UTC
  The glibc implementation of iseqsig relies on ordered comparison
operators raising the "invalid" exception for quiet NaN operands, with
a workaround on platforms where a GCC bug means that exception is not
raised.  For x86, that bug has now been fixed for GCC 8, so this patch
disables the workaround in that case.  If and when the corresponding
bugs for powerpc and s390 are fixed, the headers for those platforms
should of course be updated similarly.

Tested for x86_64 and x86, including with GCC mainline.  Note that
other failures appear with GCC mainline because of spurious use of
ordered comparison instructions for unordered operations
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82692>.  Committed.

2017-10-24  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
	(FIX_COMPARE_INVALID): Define to 0 if [__GNUC_PREREQ (8, 0)].
  

Comments

H.J. Lu Oct. 26, 2017, 11:28 a.m. UTC | #1
On Mon, Oct 23, 2017 at 5:33 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> The glibc implementation of iseqsig relies on ordered comparison
> operators raising the "invalid" exception for quiet NaN operands, with
> a workaround on platforms where a GCC bug means that exception is not
> raised.  For x86, that bug has now been fixed for GCC 8, so this patch
> disables the workaround in that case.  If and when the corresponding
> bugs for powerpc and s390 are fixed, the headers for those platforms
> should of course be updated similarly.
>
> Tested for x86_64 and x86, including with GCC mainline.  Note that
> other failures appear with GCC mainline because of spurious use of
> ordered comparison instructions for unordered operations
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82692>.  Committed.
>
> 2017-10-24  Joseph Myers  <joseph@codesourcery.com>
>
>         * sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
>         (FIX_COMPARE_INVALID): Define to 0 if [__GNUC_PREREQ (8, 0)].
>
> diff --git a/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h b/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
> index bda247d..842c945 100644
> --- a/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
> +++ b/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
> @@ -20,9 +20,13 @@
>  #ifndef FIX_FP_INT_COMPARE_INVALID_H
>  #define FIX_FP_INT_COMPARE_INVALID_H   1
>
> -/* As of GCC 5, both x87 and SSE comparisons use unordered comparison
> +/* Before GCC 8, both x87 and SSE comparisons use unordered comparison
>     instructions when they should use ordered comparisons
>     <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52451>.  */
> -#define FIX_COMPARE_INVALID 1
> +#if __GNUC_PREREQ (8, 0)
> +# define FIX_COMPARE_INVALID 0
> +#else
> +# define FIX_COMPARE_INVALID 1
> +#endif
>
>  #endif /* fix-fp-int-compare-invalid.h */
>
> --
> Joseph S. Myers
> joseph@codesourcery.com

Does this fix

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82733
  

Patch

diff --git a/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h b/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
index bda247d..842c945 100644
--- a/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
+++ b/sysdeps/x86/fpu/fix-fp-int-compare-invalid.h
@@ -20,9 +20,13 @@ 
 #ifndef FIX_FP_INT_COMPARE_INVALID_H
 #define FIX_FP_INT_COMPARE_INVALID_H	1
 
-/* As of GCC 5, both x87 and SSE comparisons use unordered comparison
+/* Before GCC 8, both x87 and SSE comparisons use unordered comparison
    instructions when they should use ordered comparisons
    <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52451>.  */
-#define FIX_COMPARE_INVALID 1
+#if __GNUC_PREREQ (8, 0)
+# define FIX_COMPARE_INVALID 0
+#else
+# define FIX_COMPARE_INVALID 1
+#endif
 
 #endif /* fix-fp-int-compare-invalid.h */