[PATCH 4/5] x86 long double: Consider pseudo numbers as signaling

Siddhesh Poyarekar siddhesh@sourceware.org
Tue Dec 15 14:13:38 GMT 2020


Implement a separate x86 version of issignalingl that returns true for
pseudo-normal numbers.

Also drop comment from the generic version of s_issignalingl since it
is no longer true or relevant.
---
 sysdeps/ieee754/ldbl-96/s_issignalingl.c |  2 --
 sysdeps/x86/fpu/s_issignalingl.c         | 39 ++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 sysdeps/x86/fpu/s_issignalingl.c

diff --git a/sysdeps/ieee754/ldbl-96/s_issignalingl.c b/sysdeps/ieee754/ldbl-96/s_issignalingl.c
index ec542ad468..2aa0ffae0e 100644
--- a/sysdeps/ieee754/ldbl-96/s_issignalingl.c
+++ b/sysdeps/ieee754/ldbl-96/s_issignalingl.c
@@ -34,8 +34,6 @@ __issignalingl (long double x)
   hxi ^= 0x40000000;
   /* If lxi != 0, then set any suitable bit of the significand in hxi.  */
   hxi |= (lxi | -lxi) >> 31;
-  /* We do not recognize a pseudo NaN as sNaN; they're invalid on 80387 and
-     later.  */
   /* We have to compare for greater (instead of greater or equal), because x's
      significand being all-zero designates infinity not NaN.  */
   return ((exi & 0x7fff) == 0x7fff) && (hxi > 0xc0000000);
diff --git a/sysdeps/x86/fpu/s_issignalingl.c b/sysdeps/x86/fpu/s_issignalingl.c
new file mode 100644
index 0000000000..df273b881d
--- /dev/null
+++ b/sysdeps/x86/fpu/s_issignalingl.c
@@ -0,0 +1,39 @@
+/* Test for signaling NaN - x86 version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_private.h>
+#include <nan-high-order-bit.h>
+#include "sysdeps/x86/fpu/isnanl_common.h"
+
+int
+__issignalingl (long double x)
+{
+  uint32_t exi, hxi, lxi, nan, pn;
+  GET_LDOUBLE_WORDS (exi, hxi, lxi, x);
+#if HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+# error not implemented
+#else
+  nan = x86_isnanl (exi, hxi, lxi);
+  pn = (~hxi & 0x80000000) >> 31;
+  hxi = (~hxi & 0x40000000) >> 30;
+
+  return nan & (pn | hxi);
+#endif
+}
+libm_hidden_def (__issignalingl)
-- 
2.29.2



More information about the Libc-alpha mailing list