This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

soft-fp: make ordered comparisons raise "invalid" for quiet NaNs (bug 14910)


The C ordered comparisons < <= > >= should raise the "invalid"
exception for all NaN operands; it's only == and != that should do so
for signaling but not quiet NaNs.  This patch fixes the affected
soft-fp functions accordingly.

Tested for powerpc-nofpu.  Note: because of the GCC bug with built-in
fabsl expansion for soft-float (see sysdeps/powerpc/nofpu/Makefile),
this introduces spurious "invalid" exceptions where calls to fabsl
wrongly result in ordered comparisons.  I'm testing a patch to use
-fno-builtin-fabsl for more libm files to fix this.

2013-10-10  Joseph Myers  <joseph@codesourcery.com>

	[BZ #14910]
	* soft-fp/gedf2.c (__gedf2): Raise "invalid" exception for all
	unordered operands.
	* soft-fp/gesf2.c (__gesf2): Likewise.
	* soft-fp/getf2.c (__getf2): Likewise.
	* soft-fp/ledf2.c (__ledf2): Likewise.
	* soft-fp/lesf2.c (__lesf2): Likewise.
	* soft-fp/letf2.c (__letf2): Likewise.

diff --git a/soft-fp/gedf2.c b/soft-fp/gedf2.c
index 0ef9f5d..a6c568c 100644
--- a/soft-fp/gedf2.c
+++ b/soft-fp/gedf2.c
@@ -40,7 +40,7 @@ CMPtype __gedf2(DFtype a, DFtype b)
   FP_UNPACK_RAW_D(A, a);
   FP_UNPACK_RAW_D(B, b);
   FP_CMP_D(r, A, B, -2);
-  if (r == -2 && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B)))
+  if (r == -2)
     FP_SET_EXCEPTION(FP_EX_INVALID);
   FP_HANDLE_EXCEPTIONS;
 
diff --git a/soft-fp/gesf2.c b/soft-fp/gesf2.c
index f0a8377..b9c661a 100644
--- a/soft-fp/gesf2.c
+++ b/soft-fp/gesf2.c
@@ -40,7 +40,7 @@ CMPtype __gesf2(SFtype a, SFtype b)
   FP_UNPACK_RAW_S(A, a);
   FP_UNPACK_RAW_S(B, b);
   FP_CMP_S(r, A, B, -2);
-  if (r == -2 && (FP_ISSIGNAN_S(A) || FP_ISSIGNAN_S(B)))
+  if (r == -2)
     FP_SET_EXCEPTION(FP_EX_INVALID);
   FP_HANDLE_EXCEPTIONS;
 
diff --git a/soft-fp/getf2.c b/soft-fp/getf2.c
index 705d48b..ff67ffa 100644
--- a/soft-fp/getf2.c
+++ b/soft-fp/getf2.c
@@ -40,7 +40,7 @@ CMPtype __getf2(TFtype a, TFtype b)
   FP_UNPACK_RAW_Q(A, a);
   FP_UNPACK_RAW_Q(B, b);
   FP_CMP_Q(r, A, B, -2);
-  if (r == -2 && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
+  if (r == -2)
     FP_SET_EXCEPTION(FP_EX_INVALID);
   FP_HANDLE_EXCEPTIONS;
 
diff --git a/soft-fp/ledf2.c b/soft-fp/ledf2.c
index 7b8f403..513ef8e 100644
--- a/soft-fp/ledf2.c
+++ b/soft-fp/ledf2.c
@@ -40,7 +40,7 @@ CMPtype __ledf2(DFtype a, DFtype b)
   FP_UNPACK_RAW_D(A, a);
   FP_UNPACK_RAW_D(B, b);
   FP_CMP_D(r, A, B, 2);
-  if (r == 2 && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B)))
+  if (r == 2)
     FP_SET_EXCEPTION(FP_EX_INVALID);
   FP_HANDLE_EXCEPTIONS;
 
diff --git a/soft-fp/lesf2.c b/soft-fp/lesf2.c
index 41f823b..8f75b79 100644
--- a/soft-fp/lesf2.c
+++ b/soft-fp/lesf2.c
@@ -40,7 +40,7 @@ CMPtype __lesf2(SFtype a, SFtype b)
   FP_UNPACK_RAW_S(A, a);
   FP_UNPACK_RAW_S(B, b);
   FP_CMP_S(r, A, B, 2);
-  if (r == 2 && (FP_ISSIGNAN_S(A) || FP_ISSIGNAN_S(B)))
+  if (r == 2)
     FP_SET_EXCEPTION(FP_EX_INVALID);
   FP_HANDLE_EXCEPTIONS;
 
diff --git a/soft-fp/letf2.c b/soft-fp/letf2.c
index 59342ca..1816bdf 100644
--- a/soft-fp/letf2.c
+++ b/soft-fp/letf2.c
@@ -40,7 +40,7 @@ CMPtype __letf2(TFtype a, TFtype b)
   FP_UNPACK_RAW_Q(A, a);
   FP_UNPACK_RAW_Q(B, b);
   FP_CMP_Q(r, A, B, 2);
-  if (r == 2 && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
+  if (r == 2)
     FP_SET_EXCEPTION(FP_EX_INVALID);
   FP_HANDLE_EXCEPTIONS;
 

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]