public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add __builtin_iseqsig()
@ 2022-09-01 21:02 FX
  2022-09-09 17:55 ` FX
  0 siblings, 1 reply; 17+ messages in thread
From: FX @ 2022-09-01 21:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph S. Myers, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

Attached patch adds __builtin_iseqsig() to the middle-end and C family front-ends.
Testing does not currently check whether the signaling part works, because with optimisation is actually does not (preexisting compiler bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106805)

Bootstrapped and regtested on x86_64-linux.
OK to commit?

(I’m not very skilled for middle-end hacking, so I’m sure there will be modifications to make.)

FX

[-- Attachment #2: 0001-Add-__builtin_iseqsig.patch --]
[-- Type: application/octet-stream, Size: 10186 bytes --]

From 7d6b76de39ecad59fe69a6f5dd479e481f4c5835 Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date: Thu, 1 Sep 2022 22:49:49 +0200
Subject: [PATCH] Add __builtin_iseqsig()

iseqsig() is a C2x library function, for signaling floating-point
equality checks.  Provide a GCC-builtin for it, which is folded to
a series of comparisons.

2022-09-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

gcc/
	* doc/extend.texi: Document iseqsig builtin.
	* builtins.cc (fold_builtin_iseqsig): New function.
	(fold_builtin_2): Handle BUILT_IN_ISEQSIG.
	(is_inexpensive_builtin): Handle BUILT_IN_ISEQSIG.
	* builtins.def (BUILT_IN_ISEQSIG): New built-in.

gcc/c-family/
	* c-common.cc (check_builtin_function_arguments):
	Handle BUILT_IN_ISEQSIG.

gcc/testsuite/
	* gcc.dg/torture/builtin-iseqsig-1.c: New test.
---
 gcc/builtins.cc                               |  41 ++++++
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/doc/extend.texi                           |   7 +-
 .../gcc.dg/torture/builtin-iseqsig-1.c        | 117 ++++++++++++++++++
 5 files changed, 164 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index f1f7c0ce337..bf6bf2809d8 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -171,6 +171,7 @@ static tree fold_builtin_fabs (location_t, tree, tree);
 static tree fold_builtin_abs (location_t, tree, tree);
 static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
 					enum tree_code);
+static tree fold_builtin_iseqsig (location_t, tree, tree);
 static tree fold_builtin_varargs (location_t, tree, tree*, int);
 
 static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
@@ -9404,6 +9405,42 @@ fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
 		      fold_build2_loc (loc, code, type, arg0, arg1));
 }
 
+/* Fold a call to __builtin_iseqsig().  ARG0 and ARG1 are the arguments.
+   After choosing the wider floating-point type for the comparison,
+   the code is folded to:
+     SAVE_EXPR<ARG0> >= SAVE_EXPR<ARG1> && SAVE_EXPR<ARG0> <= SAVE_EXPR<ARG1>  */
+
+static tree
+fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree cmp1, cmp2, cmp_type = NULL_TREE;
+
+  type0 = TREE_TYPE (arg0);
+  type1 = TREE_TYPE (arg1);
+
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  if (code0 == REAL_TYPE && code1 == REAL_TYPE)
+    /* Choose the wider of two real types.  */
+    cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
+      ? type0 : type1;
+  else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
+    cmp_type = type0;
+  else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
+    cmp_type = type1;
+
+  arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
+  arg1 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg1));
+
+  cmp1 = fold_build2_loc (loc, GE_EXPR, integer_type_node, arg0, arg1);
+  cmp2 = fold_build2_loc (loc, LE_EXPR, integer_type_node, arg0, arg1);
+
+  return fold_build2_loc (loc, TRUTH_AND_EXPR, integer_type_node, cmp1, cmp2);
+}
+
 /* Fold __builtin_{,s,u}{add,sub,mul}{,l,ll}_overflow, either into normal
    arithmetics if it can never overflow, or into internal functions that
    return both result of arithmetics and overflowed boolean flag in
@@ -9791,6 +9828,9 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
 					 arg0, arg1, UNORDERED_EXPR,
 					 NOP_EXPR);
 
+    case BUILT_IN_ISEQSIG:
+      return fold_builtin_iseqsig (loc, arg0, arg1);
+
       /* We do the folding for va_start in the expander.  */
     case BUILT_IN_VA_START:
       break;
@@ -11303,6 +11343,7 @@ is_inexpensive_builtin (tree decl)
       case BUILT_IN_ISLESSEQUAL:
       case BUILT_IN_ISLESSGREATER:
       case BUILT_IN_ISUNORDERED:
+      case BUILT_IN_ISEQSIG:
       case BUILT_IN_VA_ARG_PACK:
       case BUILT_IN_VA_ARG_PACK_LEN:
       case BUILT_IN_VA_COPY:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index f0236316850..8fab9dc3f1b 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -908,6 +908,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_ISLESS, "isless", BT_FN_INT_VAR, ATTR_CONST_NOT
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSEQUAL, "islessequal", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSGREATER, "islessgreater", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISUNORDERED, "isunordered", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
+DEF_GCC_BUILTIN        (BUILT_IN_ISEQSIG, "iseqsig", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISSIGNALING, "issignaling", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_LIB_BUILTIN        (BUILT_IN_LABS, "labs", BT_FN_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_LLABS, "llabs", BT_FN_LONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 1eb842e1c7b..44d30436e47 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6330,6 +6330,7 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     case BUILT_IN_ISLESSEQUAL:
     case BUILT_IN_ISLESSGREATER:
     case BUILT_IN_ISUNORDERED:
+    case BUILT_IN_ISEQSIG:
       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
 	{
 	  enum tree_code code0, code1;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 0fedab96610..5efaf19a57f 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -12995,6 +12995,7 @@ is called and the @var{flag} argument passed to it.
 @findex __builtin_extend_pointer
 @findex __builtin_fpclassify
 @findex __builtin_has_attribute
+@findex __builtin_iseqsig
 @findex __builtin_isfinite
 @findex __builtin_isnormal
 @findex __builtin_isgreater
@@ -13555,9 +13556,9 @@ the same names as the standard macros ( @code{isgreater},
 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
 prefixed.  We intend for a library implementor to be able to simply
 @code{#define} each standard macro to its built-in equivalent.
-In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
-@code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
-@code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
+In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
+@code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
+used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
 built-in functions appear both with and without the @code{__builtin_} prefix.
 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
 built-in functions will always return 0.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
new file mode 100644
index 00000000000..3ffaaf7e15d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
@@ -0,0 +1,117 @@
+/* { dg-do run } */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+
+void
+ftrue (float x, float y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (float x, float y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+dtrue (double x, double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+dfalse (double x, double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ltrue (long double x, long double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+lfalse (long double x, long double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+
+int
+main ()
+{
+  ftrue (0.f, 0.f);
+  ftrue (0.f, -0.f);
+  ffalse (0.f, 1.f);
+  ffalse (-0.f, 1.f);
+  ffalse (0.f, __builtin_inff());
+  ffalse (-0.f, __builtin_inff());
+  ffalse (0.f, __builtin_nanf(""));
+  ffalse (-0.f, __builtin_nanf(""));
+  ftrue (1.f, 1.f);
+  ffalse (1.f, 0.f);
+  ffalse (1.f, -0.f);
+  ffalse (1.f, __builtin_inff());
+  ffalse (1.f, __builtin_nanf(""));
+  ftrue (__builtin_inff(), __builtin_inff());
+  ffalse (__builtin_inff(), __builtin_nanf(""));
+  ffalse (__builtin_nanf(""), __builtin_nanf(""));
+
+  dtrue (0., 0.);
+  dtrue (0., -0.);
+  dfalse (0., 1.);
+  dfalse (-0., 1.);
+  dfalse (0., __builtin_inf());
+  dfalse (-0., __builtin_inf());
+  dfalse (0., __builtin_nan(""));
+  dfalse (-0., __builtin_nan(""));
+  dtrue (1., 1.);
+  dfalse (1., 0.);
+  dfalse (1., -0.);
+  dfalse (1., __builtin_inf());
+  dfalse (1., __builtin_nan(""));
+  dtrue (__builtin_inf(), __builtin_inf());
+  dfalse (__builtin_inf(), __builtin_nan(""));
+  dfalse (__builtin_nan(""), __builtin_nan(""));
+
+  ltrue (0.L, 0.L);
+  ltrue (0.L, -0.L);
+  lfalse (0.L, 1.L);
+  lfalse (-0.L, 1.L);
+  lfalse (0.L, __builtin_infl());
+  lfalse (-0.L, __builtin_infl());
+  lfalse (0.L, __builtin_nanl(""));
+  lfalse (-0.L, __builtin_nanl(""));
+  ltrue (1.L, 1.L);
+  lfalse (1.L, 0.L);
+  lfalse (1.L, -0.L);
+  lfalse (1.L, __builtin_infl());
+  lfalse (1.L, __builtin_nanl(""));
+  ltrue (__builtin_infl(), __builtin_infl());
+  lfalse (__builtin_infl(), __builtin_nanl(""));
+  lfalse (__builtin_nanl(""), __builtin_nanl(""));
+
+  if (!__builtin_iseqsig (0.f, -0.))
+    __builtin_abort ();
+  if (!__builtin_iseqsig (0.f, -0.L))
+    __builtin_abort ();
+  if (!__builtin_iseqsig (0., -0.L))
+    __builtin_abort ();
+
+  if (__builtin_iseqsig (0.f, 1.))
+    __builtin_abort ();
+  if (__builtin_iseqsig (0.f, 1.L))
+    __builtin_abort ();
+  if (__builtin_iseqsig (0., 1.L))
+    __builtin_abort ();
+
+  return 0;
+}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-09-01 21:02 [PATCH] Add __builtin_iseqsig() FX
@ 2022-09-09 17:55 ` FX
  2022-09-21  9:40   ` FX
  0 siblings, 1 reply; 17+ messages in thread
From: FX @ 2022-09-09 17:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph S. Myers, Jakub Jelinek

ping


> Le 1 sept. 2022 à 23:02, FX <fxcoudert@gmail.com> a écrit :
> 
> Attached patch adds __builtin_iseqsig() to the middle-end and C family front-ends.
> Testing does not currently check whether the signaling part works, because with optimisation is actually does not (preexisting compiler bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106805)
> 
> Bootstrapped and regtested on x86_64-linux.
> OK to commit?
> 
> (I’m not very skilled for middle-end hacking, so I’m sure there will be modifications to make.)
> 
> FX
> <0001-Add-__builtin_iseqsig.patch>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-09-09 17:55 ` FX
@ 2022-09-21  9:40   ` FX
  2022-10-06  8:40     ` FX
  2022-10-29  5:10     ` Jeff Law
  0 siblings, 2 replies; 17+ messages in thread
From: FX @ 2022-09-21  9:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph S. Myers, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 8 bytes --]

ping*2


[-- Attachment #2: 0001-Add-__builtin_iseqsig.patch --]
[-- Type: application/octet-stream, Size: 10226 bytes --]

From 3c66839a95f69dfe12db651033e9df9dfbe3c719 Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date: Thu, 1 Sep 2022 22:49:49 +0200
Subject: [PATCH] Add __builtin_iseqsig()

iseqsig() is a C2x library function, for signaling floating-point
equality checks.  Provide a GCC-builtin for it, which is folded to
a series of comparisons.

2022-09-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR middle-end/77928

gcc/
	* doc/extend.texi: Document iseqsig builtin.
	* builtins.cc (fold_builtin_iseqsig): New function.
	(fold_builtin_2): Handle BUILT_IN_ISEQSIG.
	(is_inexpensive_builtin): Handle BUILT_IN_ISEQSIG.
	* builtins.def (BUILT_IN_ISEQSIG): New built-in.

gcc/c-family/
	* c-common.cc (check_builtin_function_arguments):
	Handle BUILT_IN_ISEQSIG.

gcc/testsuite/
	* gcc.dg/torture/builtin-iseqsig-1.c: New test.
---
 gcc/builtins.cc                               |  41 ++++++
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/doc/extend.texi                           |   7 +-
 .../gcc.dg/torture/builtin-iseqsig-1.c        | 117 ++++++++++++++++++
 5 files changed, 164 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 5f319b28030..b15af6f1a45 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -171,6 +171,7 @@ static tree fold_builtin_fabs (location_t, tree, tree);
 static tree fold_builtin_abs (location_t, tree, tree);
 static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
 					enum tree_code);
+static tree fold_builtin_iseqsig (location_t, tree, tree);
 static tree fold_builtin_varargs (location_t, tree, tree*, int);
 
 static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
@@ -9400,6 +9401,42 @@ fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
 		      fold_build2_loc (loc, code, type, arg0, arg1));
 }
 
+/* Fold a call to __builtin_iseqsig().  ARG0 and ARG1 are the arguments.
+   After choosing the wider floating-point type for the comparison,
+   the code is folded to:
+     SAVE_EXPR<ARG0> >= SAVE_EXPR<ARG1> && SAVE_EXPR<ARG0> <= SAVE_EXPR<ARG1>  */
+
+static tree
+fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree cmp1, cmp2, cmp_type = NULL_TREE;
+
+  type0 = TREE_TYPE (arg0);
+  type1 = TREE_TYPE (arg1);
+
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  if (code0 == REAL_TYPE && code1 == REAL_TYPE)
+    /* Choose the wider of two real types.  */
+    cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
+      ? type0 : type1;
+  else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
+    cmp_type = type0;
+  else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
+    cmp_type = type1;
+
+  arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
+  arg1 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg1));
+
+  cmp1 = fold_build2_loc (loc, GE_EXPR, integer_type_node, arg0, arg1);
+  cmp2 = fold_build2_loc (loc, LE_EXPR, integer_type_node, arg0, arg1);
+
+  return fold_build2_loc (loc, TRUTH_AND_EXPR, integer_type_node, cmp1, cmp2);
+}
+
 /* Fold __builtin_{,s,u}{add,sub,mul}{,l,ll}_overflow, either into normal
    arithmetics if it can never overflow, or into internal functions that
    return both result of arithmetics and overflowed boolean flag in
@@ -9787,6 +9824,9 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
 					 arg0, arg1, UNORDERED_EXPR,
 					 NOP_EXPR);
 
+    case BUILT_IN_ISEQSIG:
+      return fold_builtin_iseqsig (loc, arg0, arg1);
+
       /* We do the folding for va_start in the expander.  */
     case BUILT_IN_VA_START:
       break;
@@ -11299,6 +11339,7 @@ is_inexpensive_builtin (tree decl)
       case BUILT_IN_ISLESSEQUAL:
       case BUILT_IN_ISLESSGREATER:
       case BUILT_IN_ISUNORDERED:
+      case BUILT_IN_ISEQSIG:
       case BUILT_IN_VA_ARG_PACK:
       case BUILT_IN_VA_ARG_PACK_LEN:
       case BUILT_IN_VA_COPY:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index f0236316850..8fab9dc3f1b 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -908,6 +908,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_ISLESS, "isless", BT_FN_INT_VAR, ATTR_CONST_NOT
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSEQUAL, "islessequal", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSGREATER, "islessgreater", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISUNORDERED, "isunordered", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
+DEF_GCC_BUILTIN        (BUILT_IN_ISEQSIG, "iseqsig", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISSIGNALING, "issignaling", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_LIB_BUILTIN        (BUILT_IN_LABS, "labs", BT_FN_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_LLABS, "llabs", BT_FN_LONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index c0f15f4cab1..62d8e54c96d 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6329,6 +6329,7 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     case BUILT_IN_ISLESSEQUAL:
     case BUILT_IN_ISLESSGREATER:
     case BUILT_IN_ISUNORDERED:
+    case BUILT_IN_ISEQSIG:
       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
 	{
 	  enum tree_code code0, code1;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index a5afb467d23..7a02b8c47e8 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -12995,6 +12995,7 @@ is called and the @var{flag} argument passed to it.
 @findex __builtin_extend_pointer
 @findex __builtin_fpclassify
 @findex __builtin_has_attribute
+@findex __builtin_iseqsig
 @findex __builtin_isfinite
 @findex __builtin_isnormal
 @findex __builtin_isgreater
@@ -13555,9 +13556,9 @@ the same names as the standard macros ( @code{isgreater},
 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
 prefixed.  We intend for a library implementor to be able to simply
 @code{#define} each standard macro to its built-in equivalent.
-In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
-@code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
-@code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
+In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
+@code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
+used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
 built-in functions appear both with and without the @code{__builtin_} prefix.
 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
 built-in functions will always return 0.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
new file mode 100644
index 00000000000..3ffaaf7e15d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
@@ -0,0 +1,117 @@
+/* { dg-do run } */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+
+void
+ftrue (float x, float y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (float x, float y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+dtrue (double x, double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+dfalse (double x, double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ltrue (long double x, long double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+lfalse (long double x, long double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+
+int
+main ()
+{
+  ftrue (0.f, 0.f);
+  ftrue (0.f, -0.f);
+  ffalse (0.f, 1.f);
+  ffalse (-0.f, 1.f);
+  ffalse (0.f, __builtin_inff());
+  ffalse (-0.f, __builtin_inff());
+  ffalse (0.f, __builtin_nanf(""));
+  ffalse (-0.f, __builtin_nanf(""));
+  ftrue (1.f, 1.f);
+  ffalse (1.f, 0.f);
+  ffalse (1.f, -0.f);
+  ffalse (1.f, __builtin_inff());
+  ffalse (1.f, __builtin_nanf(""));
+  ftrue (__builtin_inff(), __builtin_inff());
+  ffalse (__builtin_inff(), __builtin_nanf(""));
+  ffalse (__builtin_nanf(""), __builtin_nanf(""));
+
+  dtrue (0., 0.);
+  dtrue (0., -0.);
+  dfalse (0., 1.);
+  dfalse (-0., 1.);
+  dfalse (0., __builtin_inf());
+  dfalse (-0., __builtin_inf());
+  dfalse (0., __builtin_nan(""));
+  dfalse (-0., __builtin_nan(""));
+  dtrue (1., 1.);
+  dfalse (1., 0.);
+  dfalse (1., -0.);
+  dfalse (1., __builtin_inf());
+  dfalse (1., __builtin_nan(""));
+  dtrue (__builtin_inf(), __builtin_inf());
+  dfalse (__builtin_inf(), __builtin_nan(""));
+  dfalse (__builtin_nan(""), __builtin_nan(""));
+
+  ltrue (0.L, 0.L);
+  ltrue (0.L, -0.L);
+  lfalse (0.L, 1.L);
+  lfalse (-0.L, 1.L);
+  lfalse (0.L, __builtin_infl());
+  lfalse (-0.L, __builtin_infl());
+  lfalse (0.L, __builtin_nanl(""));
+  lfalse (-0.L, __builtin_nanl(""));
+  ltrue (1.L, 1.L);
+  lfalse (1.L, 0.L);
+  lfalse (1.L, -0.L);
+  lfalse (1.L, __builtin_infl());
+  lfalse (1.L, __builtin_nanl(""));
+  ltrue (__builtin_infl(), __builtin_infl());
+  lfalse (__builtin_infl(), __builtin_nanl(""));
+  lfalse (__builtin_nanl(""), __builtin_nanl(""));
+
+  if (!__builtin_iseqsig (0.f, -0.))
+    __builtin_abort ();
+  if (!__builtin_iseqsig (0.f, -0.L))
+    __builtin_abort ();
+  if (!__builtin_iseqsig (0., -0.L))
+    __builtin_abort ();
+
+  if (__builtin_iseqsig (0.f, 1.))
+    __builtin_abort ();
+  if (__builtin_iseqsig (0.f, 1.L))
+    __builtin_abort ();
+  if (__builtin_iseqsig (0., 1.L))
+    __builtin_abort ();
+
+  return 0;
+}
-- 
2.37.0 (Apple Git-136)


[-- Attachment #3: Type: text/plain, Size: 682 bytes --]



> Le 9 sept. 2022 à 19:55, FX <fxcoudert@gmail.com> a écrit :
> 
> ping
> 
> 
>> Le 1 sept. 2022 à 23:02, FX <fxcoudert@gmail.com> a écrit :
>> 
>> Attached patch adds __builtin_iseqsig() to the middle-end and C family front-ends.
>> Testing does not currently check whether the signaling part works, because with optimisation is actually does not (preexisting compiler bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106805)
>> 
>> Bootstrapped and regtested on x86_64-linux.
>> OK to commit?
>> 
>> (I’m not very skilled for middle-end hacking, so I’m sure there will be modifications to make.)
>> 
>> FX
>> <0001-Add-__builtin_iseqsig.patch>
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-09-21  9:40   ` FX
@ 2022-10-06  8:40     ` FX
  2022-10-06 21:46       ` Joseph Myers
  2022-10-29  5:10     ` Jeff Law
  1 sibling, 1 reply; 17+ messages in thread
From: FX @ 2022-10-06  8:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph S. Myers, Jakub Jelinek

ping*3
please?


> Le 21 sept. 2022 à 11:40, FX <fxcoudert@gmail.com> a écrit :
> 
> ping*2
> 
> <0001-Add-__builtin_iseqsig.patch>
> 
>> Le 9 sept. 2022 à 19:55, FX <fxcoudert@gmail.com> a écrit :
>> 
>> ping
>> 
>> 
>>> Le 1 sept. 2022 à 23:02, FX <fxcoudert@gmail.com> a écrit :
>>> 
>>> Attached patch adds __builtin_iseqsig() to the middle-end and C family front-ends.
>>> Testing does not currently check whether the signaling part works, because with optimisation is actually does not (preexisting compiler bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106805)
>>> 
>>> Bootstrapped and regtested on x86_64-linux.
>>> OK to commit?
>>> 
>>> (I’m not very skilled for middle-end hacking, so I’m sure there will be modifications to make.)
>>> 
>>> FX
>>> <0001-Add-__builtin_iseqsig.patch>
>> 
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-10-06  8:40     ` FX
@ 2022-10-06 21:46       ` Joseph Myers
  2023-06-06 18:15         ` FX Coudert
  0 siblings, 1 reply; 17+ messages in thread
From: Joseph Myers @ 2022-10-06 21:46 UTC (permalink / raw)
  To: FX; +Cc: gcc-patches, Jakub Jelinek

My reading of the bug given as a reason for not testing that FE_INVALID is 
raised for (both quiet and signaling) NaN arguments is that it's 
specifically about constant arguments.  That is, it ought to be possible 
to have a testcase that verifies FE_INVALID is raised when appropriate 
(and not when inappropriate) provided the arguments come from volatile 
variables rather than directly from constants.  (There would still need to 
be a powerpc*-*-* XFAIL referencing bug 58684.)  Only a test for constant 
arguments would need to wait on a fix for bug 106805.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-09-21  9:40   ` FX
  2022-10-06  8:40     ` FX
@ 2022-10-29  5:10     ` Jeff Law
  2022-10-31 18:24       ` Joseph Myers
  1 sibling, 1 reply; 17+ messages in thread
From: Jeff Law @ 2022-10-29  5:10 UTC (permalink / raw)
  To: FX, gcc-patches; +Cc: Jakub Jelinek, Joseph S. Myers


On 9/21/22 03:40, FX via Gcc-patches wrote:
> ping*2
>
>
>
>> Le 9 sept. 2022 à 19:55, FX <fxcoudert@gmail.com> a écrit :
>>
>> ping
>>
>>
>>> Le 1 sept. 2022 à 23:02, FX <fxcoudert@gmail.com> a écrit :
>>>
>>> Attached patch adds __builtin_iseqsig() to the middle-end and C family front-ends.
>>> Testing does not currently check whether the signaling part works, because with optimisation is actually does not (preexisting compiler bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106805)
>>>
>>> Bootstrapped and regtested on x86_64-linux.
>>> OK to commit?
>>>
>>> (I’m not very skilled for middle-end hacking, so I’m sure there will be modifications to make.)
>>>
>>> FX
>>> <0001-Add-__builtin_iseqsig.patch>

Joseph, do you have bits in this space that are going to be landing 
soon, or is your C2X work focused elsewhere?  Are there other C2X 
routines we need to be proving builtins for?


Jeff


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-10-29  5:10     ` Jeff Law
@ 2022-10-31 18:24       ` Joseph Myers
  2022-10-31 19:15         ` FX
  0 siblings, 1 reply; 17+ messages in thread
From: Joseph Myers @ 2022-10-31 18:24 UTC (permalink / raw)
  To: Jeff Law; +Cc: FX, gcc-patches, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 1810 bytes --]

On Fri, 28 Oct 2022, Jeff Law via Gcc-patches wrote:

> Joseph, do you have bits in this space that are going to be landing soon, or
> is your C2X work focused elsewhere?  Are there other C2X routines we need to
> be proving builtins for?

I don't have any builtins work planned for GCC 13 (maybe adjustments to 
__builtin_tgmath semantics to match changes in C2X, but that's a keyword, 
not a built-in function).

See <https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603012.html> 
for my comments on (the tests in) this patch.

Lots of <math.h> functions could sensibly have built-in versions, whether 
for inline expansion, optimization for constant arguments or both.  Note 
that for those added from TS 18661-4, it will be more convenient to add 
glibc support once MPFR 4.2 is out so that gen-auto-libm-tests doesn't 
depend on an unreleased MPFR version, and likewise MPFR 4.2 will be needed 
for optimizing those functions for constant arguments.  But other 
highlights for which built-in functions might make sense in some cases 
include: issubnormal, iszero (see bugs 77925 / 77926, where Tamar 
Christina's patch needed to be reverted); probably the fromfp functions 
(but note that the interface in C2X is different from that in TS 18661-1 
and I haven't yet implemented those changes in glibc); the functions that 
round their result to a narrower type (supported as hardware operations on 
current POWER, I think); the functions bound to new maximum / minimum 
operations from IEEEE 754-2019 (some of which are supported by RISC-V 
instructions).  Also the <stdbit.h> functions; I expect to implement those 
for glibc largely using existing built-in functions, but more direct 
built-in function support for the <stdbit.h> names may make sense.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-10-31 18:24       ` Joseph Myers
@ 2022-10-31 19:15         ` FX
  2022-10-31 22:35           ` Joseph Myers
  2022-11-20 17:10           ` Jeff Law
  0 siblings, 2 replies; 17+ messages in thread
From: FX @ 2022-10-31 19:15 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Jeff Law, gcc-patches, Jakub Jelinek

Hi,

Just adding, from the Fortran 2018 perspective, things we will need to implement for which I think support from the middle-end might be necessary:

- rounded conversions: converting, from an integer or floating point type, into another floating point type, with specific rounding mode passed as argument
- conversion to integer: converting, from a floating point type, into an integer type, with specific rounding mode passed as argument
- IEEE operations corresponding to nextDown and nextUp (or are those already available? I have not checked the fine print)

I would like to add them all for GCC 13.

FX

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-10-31 19:15         ` FX
@ 2022-10-31 22:35           ` Joseph Myers
  2022-11-20 17:10           ` Jeff Law
  1 sibling, 0 replies; 17+ messages in thread
From: Joseph Myers @ 2022-10-31 22:35 UTC (permalink / raw)
  To: FX; +Cc: Jakub Jelinek, gcc-patches

On Mon, 31 Oct 2022, FX via Gcc-patches wrote:

> - rounded conversions: converting, from an integer or floating point 
> type, into another floating point type, with specific rounding mode 
> passed as argument

These don't have standard C names.  The way to do these in C would be 
using the FENV_ROUND pragma around a conversion, but we don't support any 
of the standard pragmas including those from C99 and they would be a large 
project (cf. Marc Glisse's -ffenv-access patches from August 2020 - 
although some things in FENV_ACCESS are probably rather orthogonal to 
FENV_ROUND, I expect what's required in terms of preventing unwanted code 
movement across rounding mode changes is similar).

It might be possible to add built-in functions for such conversions 
without needing the FENV_ROUND machinery, if you make them expand to insn 
patterns (with temporary rounding mode changes) that are arranged so the 
compiler can't split them up.

(There's a principle of not introducing libm dependencies in code not 
using any <math.h>, <fenv.h> or <complex.h> functions or corresponding 
built-in functions, which would be an issue for generating calls to 
fesetround, inline or in libgcc, from such an operation.  But arguably, 
even if FENV_ROUND shouldn't introduce such dependencies - my assumption 
being that FENV_ROUND should involve target-specific inline 
implementations of the required rounding mode changes - it might be OK to 
document some GCC-specific built-in function as doing so.)

> - conversion to integer: converting, from a floating point type, into an 
> integer type, with specific rounding mode passed as argument

See the fromfp functions (signed and unsigned versions, versions with and 
without raising inexact, rounding mode specified as one of the FP_INT_* 
macros from <math.h>).  The versions in TS 18661-1 produced results in an 
integer type (intmax_t / uintmax_t, with the actual width for the 
conversion passed as an argument).  *But* C2X changed that to return the 
result in a floating-point type instead (as part of reducing the use of 
intmax_t in interfaces) - I haven't yet implemented that change in glibc.  
So the way to do such a conversion to an integer type in C2X involves 
calling such a function and then converting its result to that integer 
type.

GCC certainly knows about handling such a pair (<math.h> function, 
conversion of its result) as a built-in function (e.g. __builtin_iceil).  
My guess is that in most cases only selected calls would be expanded 
inline - calls where not only is there an appropriate conversion to an 
integer type (matching, or maybe wider than, the width passed to the 
function), but where also the function, rounding mode and width together 
match an operation for which there is a hardware instruction, with other 
cases (including ones where the rounding mode or width aren't constant) 
ending up as runtime calls (unless optimized for constant arguments).  So 
while the interfaces exist in C2X, the built-in function support in GCC 
may be fairly complicated, with the existence of the older TS 18661-1 
version of the functions complicating things further.

> - IEEE operations corresponding to nextDown and nextUp (or are those 
> already available? I have not checked the fine print)

nextdown and nextup have been in glibc since version 2.24.  I expect that 
adding built-in functions that optimize them for constant arguments would 
be straightforward (that doesn't help if what you actually want it some 
way to support those operations at runtime for targets without the 
functions in libm, of course).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-10-31 19:15         ` FX
  2022-10-31 22:35           ` Joseph Myers
@ 2022-11-20 17:10           ` Jeff Law
  2022-11-20 17:28             ` FX
  1 sibling, 1 reply; 17+ messages in thread
From: Jeff Law @ 2022-11-20 17:10 UTC (permalink / raw)
  To: FX, Joseph Myers; +Cc: gcc-patches, Jakub Jelinek


On 10/31/22 13:15, FX wrote:
> Hi,
>
> Just adding, from the Fortran 2018 perspective, things we will need to implement for which I think support from the middle-end might be necessary:
>
> - rounded conversions: converting, from an integer or floating point type, into another floating point type, with specific rounding mode passed as argument
> - conversion to integer: converting, from a floating point type, into an integer type, with specific rounding mode passed as argument
> - IEEE operations corresponding to nextDown and nextUp (or are those already available? I have not checked the fine print)
>
> I would like to add them all for GCC 13.

If you want them all for GCC 13, then you're going to need to make a 
case for a policy exception to add them after stage1 has closed.


Joseph's reply earlier in this thread has indicated a desire to verify 
that verifies FE_INVALID is raised when appropriate and not raised when 
inappropriate when the arguments come from volatile variables rather 
than directly from constants.

The patch itself looks pretty reasonable.  So let's get the testing 
coverage Joseph wanted so we can move forward.


Jeff

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2022-11-20 17:10           ` Jeff Law
@ 2022-11-20 17:28             ` FX
  0 siblings, 0 replies; 17+ messages in thread
From: FX @ 2022-11-20 17:28 UTC (permalink / raw)
  To: Jeff Law; +Cc: Joseph Myers, gcc-patches, Jakub Jelinek

Hi,

> Joseph's reply earlier in this thread has indicated a desire to verify that verifies FE_INVALID is raised when appropriate and not raised when inappropriate when the arguments come from volatile variables rather than directly from constants.
> 
> The patch itself looks pretty reasonable.  So let's get the testing coverage Joseph wanted so we can move forward.

Sadly, while I had some time to deal with it when the patch was originally submitted, once the review came back my hands were full and right now I cannot find time. I hope someone can pick it up and finish, otherwise it will have to wait for the next version.

FX


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] Add __builtin_iseqsig()
  2022-10-06 21:46       ` Joseph Myers
@ 2023-06-06 18:15         ` FX Coudert
  2023-06-13 16:49           ` FX Coudert
                             ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: FX Coudert @ 2023-06-06 18:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

Hi,

(It took me a while to get back to this.)

This is a new and improved version of the patch at https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602932.html
It addresses the comment from Joseph that FE_INVALID should really be tested in the case of both quiet and signaling NaNs, which is now done systematically.

Bootstrapped and regtested on x86_64-pc-linux-gnu
OK to commit?

FX


[-- Attachment #2: 0001-Add-__builtin_iseqsig.patch --]
[-- Type: application/octet-stream, Size: 17359 bytes --]

From 46833574721f363cbbde032dcf8205340eeae468 Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date: Thu, 1 Sep 2022 22:49:49 +0200
Subject: [PATCH 1/2] Add __builtin_iseqsig()

iseqsig() is a C2x library function, for signaling floating-point
equality checks.  Provide a GCC-builtin for it, which is folded to
a series of comparisons.

2022-09-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR middle-end/77928

gcc/
	* doc/extend.texi: Document iseqsig builtin.
	* builtins.cc (fold_builtin_iseqsig): New function.
	(fold_builtin_2): Handle BUILT_IN_ISEQSIG.
	(is_inexpensive_builtin): Handle BUILT_IN_ISEQSIG.
	* builtins.def (BUILT_IN_ISEQSIG): New built-in.

gcc/c-family/
	* c-common.cc (check_builtin_function_arguments):
	Handle BUILT_IN_ISEQSIG.

gcc/testsuite/
	* gcc.dg/torture/builtin-iseqsig-1.c: New test.
	* gcc.dg/torture/builtin-iseqsig-2.c: New test.
	* gcc.dg/torture/builtin-iseqsig-3.c: New test.
---
 gcc/builtins.cc                               |  41 +++++++
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/doc/extend.texi                           |   7 +-
 .../gcc.dg/torture/builtin-iseqsig-1.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-2.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-3.c        | 113 ++++++++++++++++++
 7 files changed, 386 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 8400adaf5b4..9fd44cf7fcd 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -171,6 +171,7 @@ static tree fold_builtin_fabs (location_t, tree, tree);
 static tree fold_builtin_abs (location_t, tree, tree);
 static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
 					enum tree_code);
+static tree fold_builtin_iseqsig (location_t, tree, tree);
 static tree fold_builtin_varargs (location_t, tree, tree*, int);
 
 static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
@@ -9445,6 +9446,42 @@ fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
 		      fold_build2_loc (loc, code, type, arg0, arg1));
 }
 
+/* Fold a call to __builtin_iseqsig().  ARG0 and ARG1 are the arguments.
+   After choosing the wider floating-point type for the comparison,
+   the code is folded to:
+     SAVE_EXPR<ARG0> >= SAVE_EXPR<ARG1> && SAVE_EXPR<ARG0> <= SAVE_EXPR<ARG1>  */
+
+static tree
+fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree cmp1, cmp2, cmp_type = NULL_TREE;
+
+  type0 = TREE_TYPE (arg0);
+  type1 = TREE_TYPE (arg1);
+
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  if (code0 == REAL_TYPE && code1 == REAL_TYPE)
+    /* Choose the wider of two real types.  */
+    cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
+      ? type0 : type1;
+  else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
+    cmp_type = type0;
+  else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
+    cmp_type = type1;
+
+  arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
+  arg1 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg1));
+
+  cmp1 = fold_build2_loc (loc, GE_EXPR, integer_type_node, arg0, arg1);
+  cmp2 = fold_build2_loc (loc, LE_EXPR, integer_type_node, arg0, arg1);
+
+  return fold_build2_loc (loc, TRUTH_AND_EXPR, integer_type_node, cmp1, cmp2);
+}
+
 /* Fold __builtin_{,s,u}{add,sub,mul}{,l,ll}_overflow, either into normal
    arithmetics if it can never overflow, or into internal functions that
    return both result of arithmetics and overflowed boolean flag in
@@ -9833,6 +9870,9 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
 					 arg0, arg1, UNORDERED_EXPR,
 					 NOP_EXPR);
 
+    case BUILT_IN_ISEQSIG:
+      return fold_builtin_iseqsig (loc, arg0, arg1);
+
       /* We do the folding for va_start in the expander.  */
     case BUILT_IN_VA_START:
       break;
@@ -11343,6 +11383,7 @@ is_inexpensive_builtin (tree decl)
       case BUILT_IN_ISLESSEQUAL:
       case BUILT_IN_ISLESSGREATER:
       case BUILT_IN_ISUNORDERED:
+      case BUILT_IN_ISEQSIG:
       case BUILT_IN_VA_ARG_PACK:
       case BUILT_IN_VA_ARG_PACK_LEN:
       case BUILT_IN_VA_COPY:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 4ad95a12f83..8cc282c1b87 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -1023,6 +1023,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_ISLESS, "isless", BT_FN_INT_VAR, ATTR_CONST_NOT
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSEQUAL, "islessequal", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSGREATER, "islessgreater", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISUNORDERED, "isunordered", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
+DEF_GCC_BUILTIN        (BUILT_IN_ISEQSIG, "iseqsig", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISSIGNALING, "issignaling", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_LIB_BUILTIN        (BUILT_IN_LABS, "labs", BT_FN_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_LLABS, "llabs", BT_FN_LONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 9c8eed5442a..9e1ce2a2bc9 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6330,6 +6330,7 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     case BUILT_IN_ISLESSEQUAL:
     case BUILT_IN_ISLESSGREATER:
     case BUILT_IN_ISUNORDERED:
+    case BUILT_IN_ISEQSIG:
       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
 	{
 	  enum tree_code code0, code1;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index cdbd4b34a35..360389df9dc 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13017,6 +13017,7 @@ is called and the @var{flag} argument passed to it.
 @node Other Builtins
 @section Other Built-in Functions Provided by GCC
 @cindex built-in functions
+@findex __builtin_iseqsig
 @findex __builtin_isfinite
 @findex __builtin_isnormal
 @findex __builtin_isgreater
@@ -13568,9 +13569,9 @@ the same names as the standard macros ( @code{isgreater},
 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
 prefixed.  We intend for a library implementor to be able to simply
 @code{#define} each standard macro to its built-in equivalent.
-In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
-@code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
-@code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
+In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
+@code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
+used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
 built-in functions appear both with and without the @code{__builtin_} prefix.
 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
 built-in functions will always return 0.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
new file mode 100644
index 00000000000..c66431fff1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+
+void
+ftrue (float x, float y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (float x, float y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile float f1, f2;
+
+  f1 = 0.f; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inff(); f2 = __builtin_inff();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inff(); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanf(""); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = 1.f;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
new file mode 100644
index 00000000000..03625b07e6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_double } */
+
+#include <fenv.h>
+
+void
+ftrue (double x, double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (double x, double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile double f1, f2;
+
+  f1 = 0.; f2 = 0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = -0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = 1.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = 0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = -0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inf(); f2 = __builtin_inf();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inf(); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nan(""); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = 1.;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
new file mode 100644
index 00000000000..ed24035264a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_long_double } */
+
+#include <fenv.h>
+
+void
+ftrue (long double x, long double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (long double x, long double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile long double f1, f2;
+
+  f1 = 0.L; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_infl(); f2 = __builtin_infl();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_infl(); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanl(""); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = 1.L;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2023-06-06 18:15         ` FX Coudert
@ 2023-06-13 16:49           ` FX Coudert
  2023-06-26  8:59           ` FX Coudert
  2023-07-19 14:48           ` FX Coudert
  2 siblings, 0 replies; 17+ messages in thread
From: FX Coudert @ 2023-06-13 16:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

ping


> Hi,
> 
> (It took me a while to get back to this.)
> 
> This is a new and improved version of the patch at https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602932.html
> It addresses the comment from Joseph that FE_INVALID should really be tested in the case of both quiet and signaling NaNs, which is now done systematically.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu
> OK to commit?
> 
> FX

[-- Attachment #2: 0001-Add-__builtin_iseqsig.patch --]
[-- Type: application/octet-stream, Size: 17359 bytes --]

From 46833574721f363cbbde032dcf8205340eeae468 Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date: Thu, 1 Sep 2022 22:49:49 +0200
Subject: [PATCH 1/2] Add __builtin_iseqsig()

iseqsig() is a C2x library function, for signaling floating-point
equality checks.  Provide a GCC-builtin for it, which is folded to
a series of comparisons.

2022-09-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR middle-end/77928

gcc/
	* doc/extend.texi: Document iseqsig builtin.
	* builtins.cc (fold_builtin_iseqsig): New function.
	(fold_builtin_2): Handle BUILT_IN_ISEQSIG.
	(is_inexpensive_builtin): Handle BUILT_IN_ISEQSIG.
	* builtins.def (BUILT_IN_ISEQSIG): New built-in.

gcc/c-family/
	* c-common.cc (check_builtin_function_arguments):
	Handle BUILT_IN_ISEQSIG.

gcc/testsuite/
	* gcc.dg/torture/builtin-iseqsig-1.c: New test.
	* gcc.dg/torture/builtin-iseqsig-2.c: New test.
	* gcc.dg/torture/builtin-iseqsig-3.c: New test.
---
 gcc/builtins.cc                               |  41 +++++++
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/doc/extend.texi                           |   7 +-
 .../gcc.dg/torture/builtin-iseqsig-1.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-2.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-3.c        | 113 ++++++++++++++++++
 7 files changed, 386 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 8400adaf5b4..9fd44cf7fcd 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -171,6 +171,7 @@ static tree fold_builtin_fabs (location_t, tree, tree);
 static tree fold_builtin_abs (location_t, tree, tree);
 static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
 					enum tree_code);
+static tree fold_builtin_iseqsig (location_t, tree, tree);
 static tree fold_builtin_varargs (location_t, tree, tree*, int);
 
 static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
@@ -9445,6 +9446,42 @@ fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
 		      fold_build2_loc (loc, code, type, arg0, arg1));
 }
 
+/* Fold a call to __builtin_iseqsig().  ARG0 and ARG1 are the arguments.
+   After choosing the wider floating-point type for the comparison,
+   the code is folded to:
+     SAVE_EXPR<ARG0> >= SAVE_EXPR<ARG1> && SAVE_EXPR<ARG0> <= SAVE_EXPR<ARG1>  */
+
+static tree
+fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree cmp1, cmp2, cmp_type = NULL_TREE;
+
+  type0 = TREE_TYPE (arg0);
+  type1 = TREE_TYPE (arg1);
+
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  if (code0 == REAL_TYPE && code1 == REAL_TYPE)
+    /* Choose the wider of two real types.  */
+    cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
+      ? type0 : type1;
+  else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
+    cmp_type = type0;
+  else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
+    cmp_type = type1;
+
+  arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
+  arg1 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg1));
+
+  cmp1 = fold_build2_loc (loc, GE_EXPR, integer_type_node, arg0, arg1);
+  cmp2 = fold_build2_loc (loc, LE_EXPR, integer_type_node, arg0, arg1);
+
+  return fold_build2_loc (loc, TRUTH_AND_EXPR, integer_type_node, cmp1, cmp2);
+}
+
 /* Fold __builtin_{,s,u}{add,sub,mul}{,l,ll}_overflow, either into normal
    arithmetics if it can never overflow, or into internal functions that
    return both result of arithmetics and overflowed boolean flag in
@@ -9833,6 +9870,9 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
 					 arg0, arg1, UNORDERED_EXPR,
 					 NOP_EXPR);
 
+    case BUILT_IN_ISEQSIG:
+      return fold_builtin_iseqsig (loc, arg0, arg1);
+
       /* We do the folding for va_start in the expander.  */
     case BUILT_IN_VA_START:
       break;
@@ -11343,6 +11383,7 @@ is_inexpensive_builtin (tree decl)
       case BUILT_IN_ISLESSEQUAL:
       case BUILT_IN_ISLESSGREATER:
       case BUILT_IN_ISUNORDERED:
+      case BUILT_IN_ISEQSIG:
       case BUILT_IN_VA_ARG_PACK:
       case BUILT_IN_VA_ARG_PACK_LEN:
       case BUILT_IN_VA_COPY:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 4ad95a12f83..8cc282c1b87 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -1023,6 +1023,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_ISLESS, "isless", BT_FN_INT_VAR, ATTR_CONST_NOT
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSEQUAL, "islessequal", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSGREATER, "islessgreater", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISUNORDERED, "isunordered", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
+DEF_GCC_BUILTIN        (BUILT_IN_ISEQSIG, "iseqsig", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISSIGNALING, "issignaling", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_LIB_BUILTIN        (BUILT_IN_LABS, "labs", BT_FN_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_LLABS, "llabs", BT_FN_LONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 9c8eed5442a..9e1ce2a2bc9 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6330,6 +6330,7 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     case BUILT_IN_ISLESSEQUAL:
     case BUILT_IN_ISLESSGREATER:
     case BUILT_IN_ISUNORDERED:
+    case BUILT_IN_ISEQSIG:
       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
 	{
 	  enum tree_code code0, code1;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index cdbd4b34a35..360389df9dc 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13017,6 +13017,7 @@ is called and the @var{flag} argument passed to it.
 @node Other Builtins
 @section Other Built-in Functions Provided by GCC
 @cindex built-in functions
+@findex __builtin_iseqsig
 @findex __builtin_isfinite
 @findex __builtin_isnormal
 @findex __builtin_isgreater
@@ -13568,9 +13569,9 @@ the same names as the standard macros ( @code{isgreater},
 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
 prefixed.  We intend for a library implementor to be able to simply
 @code{#define} each standard macro to its built-in equivalent.
-In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
-@code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
-@code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
+In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
+@code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
+used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
 built-in functions appear both with and without the @code{__builtin_} prefix.
 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
 built-in functions will always return 0.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
new file mode 100644
index 00000000000..c66431fff1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+
+void
+ftrue (float x, float y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (float x, float y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile float f1, f2;
+
+  f1 = 0.f; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inff(); f2 = __builtin_inff();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inff(); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanf(""); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = 1.f;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
new file mode 100644
index 00000000000..03625b07e6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_double } */
+
+#include <fenv.h>
+
+void
+ftrue (double x, double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (double x, double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile double f1, f2;
+
+  f1 = 0.; f2 = 0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = -0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = 1.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = 0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = -0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inf(); f2 = __builtin_inf();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inf(); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nan(""); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = 1.;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
new file mode 100644
index 00000000000..ed24035264a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_long_double } */
+
+#include <fenv.h>
+
+void
+ftrue (long double x, long double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (long double x, long double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile long double f1, f2;
+
+  f1 = 0.L; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_infl(); f2 = __builtin_infl();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_infl(); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanl(""); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = 1.L;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2023-06-06 18:15         ` FX Coudert
  2023-06-13 16:49           ` FX Coudert
@ 2023-06-26  8:59           ` FX Coudert
  2023-07-12  9:39             ` FX Coudert
  2023-07-19 14:48           ` FX Coudert
  2 siblings, 1 reply; 17+ messages in thread
From: FX Coudert @ 2023-06-26  8:59 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

ping**2


> Le 6 juin 2023 à 20:15, FX Coudert <fxcoudert@gmail.com> a écrit :
> 
> Hi,
> 
> (It took me a while to get back to this.)
> 
> This is a new and improved version of the patch at https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602932.html
> It addresses the comment from Joseph that FE_INVALID should really be tested in the case of both quiet and signaling NaNs, which is now done systematically.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu
> OK to commit?
> 
> FX
> 
> <0001-Add-__builtin_iseqsig.patch>

[-- Attachment #2: 0001-Add-__builtin_iseqsig.patch --]
[-- Type: application/octet-stream, Size: 17359 bytes --]

From 46833574721f363cbbde032dcf8205340eeae468 Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date: Thu, 1 Sep 2022 22:49:49 +0200
Subject: [PATCH 1/2] Add __builtin_iseqsig()

iseqsig() is a C2x library function, for signaling floating-point
equality checks.  Provide a GCC-builtin for it, which is folded to
a series of comparisons.

2022-09-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR middle-end/77928

gcc/
	* doc/extend.texi: Document iseqsig builtin.
	* builtins.cc (fold_builtin_iseqsig): New function.
	(fold_builtin_2): Handle BUILT_IN_ISEQSIG.
	(is_inexpensive_builtin): Handle BUILT_IN_ISEQSIG.
	* builtins.def (BUILT_IN_ISEQSIG): New built-in.

gcc/c-family/
	* c-common.cc (check_builtin_function_arguments):
	Handle BUILT_IN_ISEQSIG.

gcc/testsuite/
	* gcc.dg/torture/builtin-iseqsig-1.c: New test.
	* gcc.dg/torture/builtin-iseqsig-2.c: New test.
	* gcc.dg/torture/builtin-iseqsig-3.c: New test.
---
 gcc/builtins.cc                               |  41 +++++++
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/doc/extend.texi                           |   7 +-
 .../gcc.dg/torture/builtin-iseqsig-1.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-2.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-3.c        | 113 ++++++++++++++++++
 7 files changed, 386 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 8400adaf5b4..9fd44cf7fcd 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -171,6 +171,7 @@ static tree fold_builtin_fabs (location_t, tree, tree);
 static tree fold_builtin_abs (location_t, tree, tree);
 static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
 					enum tree_code);
+static tree fold_builtin_iseqsig (location_t, tree, tree);
 static tree fold_builtin_varargs (location_t, tree, tree*, int);
 
 static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
@@ -9445,6 +9446,42 @@ fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
 		      fold_build2_loc (loc, code, type, arg0, arg1));
 }
 
+/* Fold a call to __builtin_iseqsig().  ARG0 and ARG1 are the arguments.
+   After choosing the wider floating-point type for the comparison,
+   the code is folded to:
+     SAVE_EXPR<ARG0> >= SAVE_EXPR<ARG1> && SAVE_EXPR<ARG0> <= SAVE_EXPR<ARG1>  */
+
+static tree
+fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree cmp1, cmp2, cmp_type = NULL_TREE;
+
+  type0 = TREE_TYPE (arg0);
+  type1 = TREE_TYPE (arg1);
+
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  if (code0 == REAL_TYPE && code1 == REAL_TYPE)
+    /* Choose the wider of two real types.  */
+    cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
+      ? type0 : type1;
+  else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
+    cmp_type = type0;
+  else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
+    cmp_type = type1;
+
+  arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
+  arg1 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg1));
+
+  cmp1 = fold_build2_loc (loc, GE_EXPR, integer_type_node, arg0, arg1);
+  cmp2 = fold_build2_loc (loc, LE_EXPR, integer_type_node, arg0, arg1);
+
+  return fold_build2_loc (loc, TRUTH_AND_EXPR, integer_type_node, cmp1, cmp2);
+}
+
 /* Fold __builtin_{,s,u}{add,sub,mul}{,l,ll}_overflow, either into normal
    arithmetics if it can never overflow, or into internal functions that
    return both result of arithmetics and overflowed boolean flag in
@@ -9833,6 +9870,9 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
 					 arg0, arg1, UNORDERED_EXPR,
 					 NOP_EXPR);
 
+    case BUILT_IN_ISEQSIG:
+      return fold_builtin_iseqsig (loc, arg0, arg1);
+
       /* We do the folding for va_start in the expander.  */
     case BUILT_IN_VA_START:
       break;
@@ -11343,6 +11383,7 @@ is_inexpensive_builtin (tree decl)
       case BUILT_IN_ISLESSEQUAL:
       case BUILT_IN_ISLESSGREATER:
       case BUILT_IN_ISUNORDERED:
+      case BUILT_IN_ISEQSIG:
       case BUILT_IN_VA_ARG_PACK:
       case BUILT_IN_VA_ARG_PACK_LEN:
       case BUILT_IN_VA_COPY:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 4ad95a12f83..8cc282c1b87 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -1023,6 +1023,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_ISLESS, "isless", BT_FN_INT_VAR, ATTR_CONST_NOT
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSEQUAL, "islessequal", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSGREATER, "islessgreater", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISUNORDERED, "isunordered", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
+DEF_GCC_BUILTIN        (BUILT_IN_ISEQSIG, "iseqsig", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISSIGNALING, "issignaling", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_LIB_BUILTIN        (BUILT_IN_LABS, "labs", BT_FN_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_LLABS, "llabs", BT_FN_LONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 9c8eed5442a..9e1ce2a2bc9 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6330,6 +6330,7 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     case BUILT_IN_ISLESSEQUAL:
     case BUILT_IN_ISLESSGREATER:
     case BUILT_IN_ISUNORDERED:
+    case BUILT_IN_ISEQSIG:
       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
 	{
 	  enum tree_code code0, code1;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index cdbd4b34a35..360389df9dc 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13017,6 +13017,7 @@ is called and the @var{flag} argument passed to it.
 @node Other Builtins
 @section Other Built-in Functions Provided by GCC
 @cindex built-in functions
+@findex __builtin_iseqsig
 @findex __builtin_isfinite
 @findex __builtin_isnormal
 @findex __builtin_isgreater
@@ -13568,9 +13569,9 @@ the same names as the standard macros ( @code{isgreater},
 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
 prefixed.  We intend for a library implementor to be able to simply
 @code{#define} each standard macro to its built-in equivalent.
-In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
-@code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
-@code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
+In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
+@code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
+used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
 built-in functions appear both with and without the @code{__builtin_} prefix.
 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
 built-in functions will always return 0.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
new file mode 100644
index 00000000000..c66431fff1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+
+void
+ftrue (float x, float y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (float x, float y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile float f1, f2;
+
+  f1 = 0.f; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inff(); f2 = __builtin_inff();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inff(); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanf(""); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = 1.f;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
new file mode 100644
index 00000000000..03625b07e6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_double } */
+
+#include <fenv.h>
+
+void
+ftrue (double x, double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (double x, double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile double f1, f2;
+
+  f1 = 0.; f2 = 0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = -0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = 1.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = 0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = -0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inf(); f2 = __builtin_inf();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inf(); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nan(""); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = 1.;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
new file mode 100644
index 00000000000..ed24035264a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_long_double } */
+
+#include <fenv.h>
+
+void
+ftrue (long double x, long double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (long double x, long double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile long double f1, f2;
+
+  f1 = 0.L; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_infl(); f2 = __builtin_infl();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_infl(); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanl(""); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = 1.L;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2023-06-26  8:59           ` FX Coudert
@ 2023-07-12  9:39             ` FX Coudert
  0 siblings, 0 replies; 17+ messages in thread
From: FX Coudert @ 2023-07-12  9:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Joseph Myers, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

ping**3


>> Le 6 juin 2023 à 20:15, FX Coudert <fxcoudert@gmail.com> a écrit :
>> 
>> Hi,
>> 
>> (It took me a while to get back to this.)
>> 
>> This is a new and improved version of the patch at https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602932.html
>> It addresses the comment from Joseph that FE_INVALID should really be tested in the case of both quiet and signaling NaNs, which is now done systematically.
>> 
>> Bootstrapped and regtested on x86_64-pc-linux-gnu
>> OK to commit?
>> 
>> FX


[-- Attachment #2: 0001-Add-__builtin_iseqsig.patch --]
[-- Type: application/octet-stream, Size: 17359 bytes --]

From 46833574721f363cbbde032dcf8205340eeae468 Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date: Thu, 1 Sep 2022 22:49:49 +0200
Subject: [PATCH 1/2] Add __builtin_iseqsig()

iseqsig() is a C2x library function, for signaling floating-point
equality checks.  Provide a GCC-builtin for it, which is folded to
a series of comparisons.

2022-09-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR middle-end/77928

gcc/
	* doc/extend.texi: Document iseqsig builtin.
	* builtins.cc (fold_builtin_iseqsig): New function.
	(fold_builtin_2): Handle BUILT_IN_ISEQSIG.
	(is_inexpensive_builtin): Handle BUILT_IN_ISEQSIG.
	* builtins.def (BUILT_IN_ISEQSIG): New built-in.

gcc/c-family/
	* c-common.cc (check_builtin_function_arguments):
	Handle BUILT_IN_ISEQSIG.

gcc/testsuite/
	* gcc.dg/torture/builtin-iseqsig-1.c: New test.
	* gcc.dg/torture/builtin-iseqsig-2.c: New test.
	* gcc.dg/torture/builtin-iseqsig-3.c: New test.
---
 gcc/builtins.cc                               |  41 +++++++
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/doc/extend.texi                           |   7 +-
 .../gcc.dg/torture/builtin-iseqsig-1.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-2.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-3.c        | 113 ++++++++++++++++++
 7 files changed, 386 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 8400adaf5b4..9fd44cf7fcd 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -171,6 +171,7 @@ static tree fold_builtin_fabs (location_t, tree, tree);
 static tree fold_builtin_abs (location_t, tree, tree);
 static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
 					enum tree_code);
+static tree fold_builtin_iseqsig (location_t, tree, tree);
 static tree fold_builtin_varargs (location_t, tree, tree*, int);
 
 static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
@@ -9445,6 +9446,42 @@ fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
 		      fold_build2_loc (loc, code, type, arg0, arg1));
 }
 
+/* Fold a call to __builtin_iseqsig().  ARG0 and ARG1 are the arguments.
+   After choosing the wider floating-point type for the comparison,
+   the code is folded to:
+     SAVE_EXPR<ARG0> >= SAVE_EXPR<ARG1> && SAVE_EXPR<ARG0> <= SAVE_EXPR<ARG1>  */
+
+static tree
+fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree cmp1, cmp2, cmp_type = NULL_TREE;
+
+  type0 = TREE_TYPE (arg0);
+  type1 = TREE_TYPE (arg1);
+
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  if (code0 == REAL_TYPE && code1 == REAL_TYPE)
+    /* Choose the wider of two real types.  */
+    cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
+      ? type0 : type1;
+  else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
+    cmp_type = type0;
+  else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
+    cmp_type = type1;
+
+  arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
+  arg1 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg1));
+
+  cmp1 = fold_build2_loc (loc, GE_EXPR, integer_type_node, arg0, arg1);
+  cmp2 = fold_build2_loc (loc, LE_EXPR, integer_type_node, arg0, arg1);
+
+  return fold_build2_loc (loc, TRUTH_AND_EXPR, integer_type_node, cmp1, cmp2);
+}
+
 /* Fold __builtin_{,s,u}{add,sub,mul}{,l,ll}_overflow, either into normal
    arithmetics if it can never overflow, or into internal functions that
    return both result of arithmetics and overflowed boolean flag in
@@ -9833,6 +9870,9 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
 					 arg0, arg1, UNORDERED_EXPR,
 					 NOP_EXPR);
 
+    case BUILT_IN_ISEQSIG:
+      return fold_builtin_iseqsig (loc, arg0, arg1);
+
       /* We do the folding for va_start in the expander.  */
     case BUILT_IN_VA_START:
       break;
@@ -11343,6 +11383,7 @@ is_inexpensive_builtin (tree decl)
       case BUILT_IN_ISLESSEQUAL:
       case BUILT_IN_ISLESSGREATER:
       case BUILT_IN_ISUNORDERED:
+      case BUILT_IN_ISEQSIG:
       case BUILT_IN_VA_ARG_PACK:
       case BUILT_IN_VA_ARG_PACK_LEN:
       case BUILT_IN_VA_COPY:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 4ad95a12f83..8cc282c1b87 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -1023,6 +1023,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_ISLESS, "isless", BT_FN_INT_VAR, ATTR_CONST_NOT
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSEQUAL, "islessequal", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSGREATER, "islessgreater", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISUNORDERED, "isunordered", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
+DEF_GCC_BUILTIN        (BUILT_IN_ISEQSIG, "iseqsig", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISSIGNALING, "issignaling", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_LIB_BUILTIN        (BUILT_IN_LABS, "labs", BT_FN_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_LLABS, "llabs", BT_FN_LONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 9c8eed5442a..9e1ce2a2bc9 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6330,6 +6330,7 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     case BUILT_IN_ISLESSEQUAL:
     case BUILT_IN_ISLESSGREATER:
     case BUILT_IN_ISUNORDERED:
+    case BUILT_IN_ISEQSIG:
       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
 	{
 	  enum tree_code code0, code1;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index cdbd4b34a35..360389df9dc 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13017,6 +13017,7 @@ is called and the @var{flag} argument passed to it.
 @node Other Builtins
 @section Other Built-in Functions Provided by GCC
 @cindex built-in functions
+@findex __builtin_iseqsig
 @findex __builtin_isfinite
 @findex __builtin_isnormal
 @findex __builtin_isgreater
@@ -13568,9 +13569,9 @@ the same names as the standard macros ( @code{isgreater},
 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
 prefixed.  We intend for a library implementor to be able to simply
 @code{#define} each standard macro to its built-in equivalent.
-In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
-@code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
-@code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
+In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
+@code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
+used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
 built-in functions appear both with and without the @code{__builtin_} prefix.
 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
 built-in functions will always return 0.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
new file mode 100644
index 00000000000..c66431fff1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+
+void
+ftrue (float x, float y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (float x, float y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile float f1, f2;
+
+  f1 = 0.f; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inff(); f2 = __builtin_inff();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inff(); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanf(""); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = 1.f;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
new file mode 100644
index 00000000000..03625b07e6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_double } */
+
+#include <fenv.h>
+
+void
+ftrue (double x, double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (double x, double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile double f1, f2;
+
+  f1 = 0.; f2 = 0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = -0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = 1.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = 0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = -0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inf(); f2 = __builtin_inf();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inf(); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nan(""); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = 1.;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
new file mode 100644
index 00000000000..ed24035264a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_long_double } */
+
+#include <fenv.h>
+
+void
+ftrue (long double x, long double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (long double x, long double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile long double f1, f2;
+
+  f1 = 0.L; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_infl(); f2 = __builtin_infl();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_infl(); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanl(""); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = 1.L;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2023-06-06 18:15         ` FX Coudert
  2023-06-13 16:49           ` FX Coudert
  2023-06-26  8:59           ` FX Coudert
@ 2023-07-19 14:48           ` FX Coudert
  2023-07-20  7:17             ` Richard Biener
  2 siblings, 1 reply; 17+ messages in thread
From: FX Coudert @ 2023-07-19 14:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Joseph Myers, rguenther

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

6 weeks later, I’d like to ask a global maintainer to review this.
The idea was okay’ed previously by Joseph Myers, but he asked for testing of both the quiet and signalling NaN cases, which is now done.

FX


> Le 6 juin 2023 à 20:15, FX Coudert <fxcoudert@gmail.com> a écrit :
> 
> Hi,
> 
> (It took me a while to get back to this.)
> 
> This is a new and improved version of the patch at https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602932.html
> It addresses the comment from Joseph that FE_INVALID should really be tested in the case of both quiet and signaling NaNs, which is now done systematically.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu
> OK to commit?
> 
> FX
> 

[-- Attachment #2: 0001-Add-__builtin_iseqsig.patch --]
[-- Type: application/octet-stream, Size: 17359 bytes --]

From 46833574721f363cbbde032dcf8205340eeae468 Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date: Thu, 1 Sep 2022 22:49:49 +0200
Subject: [PATCH 1/2] Add __builtin_iseqsig()

iseqsig() is a C2x library function, for signaling floating-point
equality checks.  Provide a GCC-builtin for it, which is folded to
a series of comparisons.

2022-09-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR middle-end/77928

gcc/
	* doc/extend.texi: Document iseqsig builtin.
	* builtins.cc (fold_builtin_iseqsig): New function.
	(fold_builtin_2): Handle BUILT_IN_ISEQSIG.
	(is_inexpensive_builtin): Handle BUILT_IN_ISEQSIG.
	* builtins.def (BUILT_IN_ISEQSIG): New built-in.

gcc/c-family/
	* c-common.cc (check_builtin_function_arguments):
	Handle BUILT_IN_ISEQSIG.

gcc/testsuite/
	* gcc.dg/torture/builtin-iseqsig-1.c: New test.
	* gcc.dg/torture/builtin-iseqsig-2.c: New test.
	* gcc.dg/torture/builtin-iseqsig-3.c: New test.
---
 gcc/builtins.cc                               |  41 +++++++
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/doc/extend.texi                           |   7 +-
 .../gcc.dg/torture/builtin-iseqsig-1.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-2.c        | 113 ++++++++++++++++++
 .../gcc.dg/torture/builtin-iseqsig-3.c        | 113 ++++++++++++++++++
 7 files changed, 386 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
 create mode 100644 gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 8400adaf5b4..9fd44cf7fcd 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -171,6 +171,7 @@ static tree fold_builtin_fabs (location_t, tree, tree);
 static tree fold_builtin_abs (location_t, tree, tree);
 static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
 					enum tree_code);
+static tree fold_builtin_iseqsig (location_t, tree, tree);
 static tree fold_builtin_varargs (location_t, tree, tree*, int);
 
 static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
@@ -9445,6 +9446,42 @@ fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
 		      fold_build2_loc (loc, code, type, arg0, arg1));
 }
 
+/* Fold a call to __builtin_iseqsig().  ARG0 and ARG1 are the arguments.
+   After choosing the wider floating-point type for the comparison,
+   the code is folded to:
+     SAVE_EXPR<ARG0> >= SAVE_EXPR<ARG1> && SAVE_EXPR<ARG0> <= SAVE_EXPR<ARG1>  */
+
+static tree
+fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree cmp1, cmp2, cmp_type = NULL_TREE;
+
+  type0 = TREE_TYPE (arg0);
+  type1 = TREE_TYPE (arg1);
+
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  if (code0 == REAL_TYPE && code1 == REAL_TYPE)
+    /* Choose the wider of two real types.  */
+    cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
+      ? type0 : type1;
+  else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
+    cmp_type = type0;
+  else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
+    cmp_type = type1;
+
+  arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
+  arg1 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg1));
+
+  cmp1 = fold_build2_loc (loc, GE_EXPR, integer_type_node, arg0, arg1);
+  cmp2 = fold_build2_loc (loc, LE_EXPR, integer_type_node, arg0, arg1);
+
+  return fold_build2_loc (loc, TRUTH_AND_EXPR, integer_type_node, cmp1, cmp2);
+}
+
 /* Fold __builtin_{,s,u}{add,sub,mul}{,l,ll}_overflow, either into normal
    arithmetics if it can never overflow, or into internal functions that
    return both result of arithmetics and overflowed boolean flag in
@@ -9833,6 +9870,9 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
 					 arg0, arg1, UNORDERED_EXPR,
 					 NOP_EXPR);
 
+    case BUILT_IN_ISEQSIG:
+      return fold_builtin_iseqsig (loc, arg0, arg1);
+
       /* We do the folding for va_start in the expander.  */
     case BUILT_IN_VA_START:
       break;
@@ -11343,6 +11383,7 @@ is_inexpensive_builtin (tree decl)
       case BUILT_IN_ISLESSEQUAL:
       case BUILT_IN_ISLESSGREATER:
       case BUILT_IN_ISUNORDERED:
+      case BUILT_IN_ISEQSIG:
       case BUILT_IN_VA_ARG_PACK:
       case BUILT_IN_VA_ARG_PACK_LEN:
       case BUILT_IN_VA_COPY:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 4ad95a12f83..8cc282c1b87 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -1023,6 +1023,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_ISLESS, "isless", BT_FN_INT_VAR, ATTR_CONST_NOT
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSEQUAL, "islessequal", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISLESSGREATER, "islessgreater", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISUNORDERED, "isunordered", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
+DEF_GCC_BUILTIN        (BUILT_IN_ISEQSIG, "iseqsig", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_GCC_BUILTIN        (BUILT_IN_ISSIGNALING, "issignaling", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF)
 DEF_LIB_BUILTIN        (BUILT_IN_LABS, "labs", BT_FN_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_LLABS, "llabs", BT_FN_LONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 9c8eed5442a..9e1ce2a2bc9 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6330,6 +6330,7 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     case BUILT_IN_ISLESSEQUAL:
     case BUILT_IN_ISLESSGREATER:
     case BUILT_IN_ISUNORDERED:
+    case BUILT_IN_ISEQSIG:
       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
 	{
 	  enum tree_code code0, code1;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index cdbd4b34a35..360389df9dc 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13017,6 +13017,7 @@ is called and the @var{flag} argument passed to it.
 @node Other Builtins
 @section Other Built-in Functions Provided by GCC
 @cindex built-in functions
+@findex __builtin_iseqsig
 @findex __builtin_isfinite
 @findex __builtin_isnormal
 @findex __builtin_isgreater
@@ -13568,9 +13569,9 @@ the same names as the standard macros ( @code{isgreater},
 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
 prefixed.  We intend for a library implementor to be able to simply
 @code{#define} each standard macro to its built-in equivalent.
-In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
-@code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
-@code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
+In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
+@code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
+used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
 built-in functions appear both with and without the @code{__builtin_} prefix.
 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
 built-in functions will always return 0.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
new file mode 100644
index 00000000000..c66431fff1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-1.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+
+void
+ftrue (float x, float y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (float x, float y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile float f1, f2;
+
+  f1 = 0.f; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_inff();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.f; f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inff(); f2 = __builtin_inff();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inff(); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanf(""); f2 = __builtin_nanf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = 1.f;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.f; f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansf(""); f2 = __builtin_nansf("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
new file mode 100644
index 00000000000..03625b07e6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-2.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_double } */
+
+#include <fenv.h>
+
+void
+ftrue (double x, double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (double x, double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile double f1, f2;
+
+  f1 = 0.; f2 = 0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = -0.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = 1.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = 1.;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = 0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = -0.;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_inf();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.; f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_inf(); f2 = __builtin_inf();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_inf(); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nan(""); f2 = __builtin_nan("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = 1.;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.; f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nans(""); f2 = __builtin_nans("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
new file mode 100644
index 00000000000..ed24035264a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-iseqsig-3.c
@@ -0,0 +1,113 @@
+/* { dg-do run { xfail powerpc*-*-* } } */
+/* remove the xfail for powerpc when pr58684 is fixed */
+/* { dg-add-options ieee } */
+/* { dg-additional-options "-fsignaling-nans" } */
+/* { dg-require-effective-target fenv_exceptions_long_double } */
+
+#include <fenv.h>
+
+void
+ftrue (long double x, long double y)
+{
+  if (!__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+void
+ffalse (long double x, long double y)
+{
+  if (__builtin_iseqsig (x, y))
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  volatile long double f1, f2;
+
+  f1 = 0.L; f2 = 0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = -0.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = 1.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = -0.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = -0.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = 1.f;
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = 0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = -0.f;
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_infl();
+  ffalse (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = 1.L; f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_infl(); f2 = __builtin_infl();
+  ftrue (f1, f2);
+  if (fetestexcept (FE_INVALID)) __builtin_abort ();
+
+  f1 = __builtin_infl(); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nanl(""); f2 = __builtin_nanl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = 1.L;
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = 1.L; f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  f1 = __builtin_nansl(""); f2 = __builtin_nansl("");
+  ffalse (f1, f2);
+  if (!fetestexcept (FE_INVALID)) __builtin_abort ();
+  feclearexcept (FE_INVALID);
+
+  return 0;
+}
-- 
2.34.1


[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Add __builtin_iseqsig()
  2023-07-19 14:48           ` FX Coudert
@ 2023-07-20  7:17             ` Richard Biener
  0 siblings, 0 replies; 17+ messages in thread
From: Richard Biener @ 2023-07-20  7:17 UTC (permalink / raw)
  To: FX Coudert; +Cc: gcc-patches, Jakub Jelinek, Joseph Myers

On Wed, 19 Jul 2023, FX Coudert wrote:

> 6 weeks later, I?d like to ask a global maintainer to review this.
> The idea was okay?ed previously by Joseph Myers, but he asked for testing of both the quiet and signalling NaN cases, which is now done.

OK.

Thanks,
Richard.

> FX
> 
> 
> > Le 6 juin 2023 ? 20:15, FX Coudert <fxcoudert@gmail.com> a ?crit :
> > 
> > Hi,
> > 
> > (It took me a while to get back to this.)
> > 
> > This is a new and improved version of the patch at https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602932.html
> > It addresses the comment from Joseph that FE_INVALID should really be tested in the case of both quiet and signaling NaNs, which is now done systematically.
> > 
> > Bootstrapped and regtested on x86_64-pc-linux-gnu
> > OK to commit?
> > 
> > FX
> > 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-07-20  7:17 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01 21:02 [PATCH] Add __builtin_iseqsig() FX
2022-09-09 17:55 ` FX
2022-09-21  9:40   ` FX
2022-10-06  8:40     ` FX
2022-10-06 21:46       ` Joseph Myers
2023-06-06 18:15         ` FX Coudert
2023-06-13 16:49           ` FX Coudert
2023-06-26  8:59           ` FX Coudert
2023-07-12  9:39             ` FX Coudert
2023-07-19 14:48           ` FX Coudert
2023-07-20  7:17             ` Richard Biener
2022-10-29  5:10     ` Jeff Law
2022-10-31 18:24       ` Joseph Myers
2022-10-31 19:15         ` FX
2022-10-31 22:35           ` Joseph Myers
2022-11-20 17:10           ` Jeff Law
2022-11-20 17:28             ` FX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).