The following adjusts -gimple dumping to dump the unordered compare ops
and *h in their GIMPLE form.  It also adds parsing for __LTGT which I
missed before.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        PR c/111468
gcc/c/
        * gimple-parser.cc (c_parser_gimple_binary_expression): Handle __LTGT.

gcc/
        * tree-pretty-print.h (op_symbol_code): Add defaulted flags
        argument.
        * tree-pretty-print.cc (op_symbol): Likewise.
        (op_symbol_code): Print TDF_GIMPLE variant if requested.
        * gimple-pretty-print.cc (dump_binary_rhs): Pass flags to
        op_symbol_code.
        (dump_gimple_cond): Likewise.

gcc/testsuite/
        * gcc.dg/gimplefe-50.c: Amend.
---
 gcc/c/gimple-parser.cc             |  5 +++++
 gcc/gimple-pretty-print.cc         |  4 ++--
 gcc/testsuite/gcc.dg/gimplefe-50.c |  1 +
 gcc/tree-pretty-print.cc           | 26 +++++++++++++-------------
 gcc/tree-pretty-print.h            |  2 +-
 5 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 9cf29701c06..f43c0398655 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -1044,6 +1044,11 @@ c_parser_gimple_binary_expression (gimple_parser 
&parser, tree ret_type)
            code = ORDERED_EXPR;
            break;
          }
+       else if (strcmp (IDENTIFIER_POINTER (id), "__LTGT") == 0)
+         {
+           code = LTGT_EXPR;
+           break;
+         }
       }
       /* Fallthru.  */
     default:
diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc
index 82017b92e89..320df9197b4 100644
--- a/gcc/gimple-pretty-print.cc
+++ b/gcc/gimple-pretty-print.cc
@@ -480,7 +480,7 @@ dump_binary_rhs (pretty_printer *buffer, const gassign *gs, 
int spc,
       else
        dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
       pp_space (buffer);
-      pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
+      pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs), flags));
       pp_space (buffer);
       if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
        {
@@ -1092,7 +1092,7 @@ dump_gimple_cond (pretty_printer *buffer, const gcond 
*gs, int spc,
                         flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : 
TDF_NONE),
                         false);
       pp_space (buffer);
-      pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
+      pp_string (buffer, op_symbol_code (gimple_cond_code (gs), flags));
       pp_space (buffer);
       dump_generic_node (buffer, gimple_cond_rhs (gs), spc,
                         flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : 
TDF_NONE),
diff --git a/gcc/testsuite/gcc.dg/gimplefe-50.c 
b/gcc/testsuite/gcc.dg/gimplefe-50.c
index 03db786b619..63d228ce76d 100644
--- a/gcc/testsuite/gcc.dg/gimplefe-50.c
+++ b/gcc/testsuite/gcc.dg/gimplefe-50.c
@@ -14,6 +14,7 @@ foo (float a, float b)
   x_7 = a_1(D) __UNEQ b_2(D);
   x_8 = a_1(D) __UNORDERED b_2(D);
   x_9 = a_1(D) __ORDERED b_2(D);
+  x_10 = a_1(D) __LTGT b_2(D);
   if (a_1(D) __UNEQ b_2(D))
     goto __BB4;
   else
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index 45a1fd3e848..12c57c14dd4 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -49,7 +49,7 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 
 /* Local functions, macros and variables.  */
-static const char *op_symbol (const_tree);
+static const char *op_symbol (const_tree, dump_flags_t = TDF_NONE);
 static void newline_and_indent (pretty_printer *, int);
 static void maybe_init_pretty_print (FILE *);
 static void print_struct_decl (pretty_printer *, const_tree, int, 
dump_flags_t);
@@ -4327,7 +4327,7 @@ op_prio (const_tree op)
 /* Return the symbol associated with operator CODE.  */
 
 const char *
-op_symbol_code (enum tree_code code)
+op_symbol_code (enum tree_code code, dump_flags_t flags)
 {
   switch (code)
     {
@@ -4354,14 +4354,14 @@ op_symbol_code (enum tree_code code)
       return "&";
 
     case ORDERED_EXPR:
-      return "ord";
+      return (flags & TDF_GIMPLE) ? "__ORDERED" : "ord";
     case UNORDERED_EXPR:
-      return "unord";
+      return (flags & TDF_GIMPLE) ? "__UNORDERED" : "unord";
 
     case EQ_EXPR:
       return "==";
     case UNEQ_EXPR:
-      return "u==";
+      return (flags & TDF_GIMPLE) ? "__UNEQ" : "u==";
 
     case NE_EXPR:
       return "!=";
@@ -4369,25 +4369,25 @@ op_symbol_code (enum tree_code code)
     case LT_EXPR:
       return "<";
     case UNLT_EXPR:
-      return "u<";
+      return (flags & TDF_GIMPLE) ? "__UNLT" : "u<";
 
     case LE_EXPR:
       return "<=";
     case UNLE_EXPR:
-      return "u<=";
+      return (flags & TDF_GIMPLE) ? "__UNLE" : "u<=";
 
     case GT_EXPR:
       return ">";
     case UNGT_EXPR:
-      return "u>";
+      return (flags & TDF_GIMPLE) ? "__UNGT" : "u>";
 
     case GE_EXPR:
       return ">=";
     case UNGE_EXPR:
-      return "u>=";
+      return (flags & TDF_GIMPLE) ? "__UNGE" : "u>=";
 
     case LTGT_EXPR:
-      return "<>";
+      return (flags & TDF_GIMPLE) ? "__LTGT" : "<>";
 
     case LSHIFT_EXPR:
       return "<<";
@@ -4417,7 +4417,7 @@ op_symbol_code (enum tree_code code)
       return "w*";
 
     case MULT_HIGHPART_EXPR:
-      return "h*";
+      return (flags & TDF_GIMPLE) ? "__MULT_HIGHPART" : "h*";
 
     case NEGATE_EXPR:
     case MINUS_EXPR:
@@ -4488,9 +4488,9 @@ op_symbol_code (enum tree_code code)
 /* Return the symbol associated with operator OP.  */
 
 static const char *
-op_symbol (const_tree op)
+op_symbol (const_tree op, dump_flags_t flags)
 {
-  return op_symbol_code (TREE_CODE (op));
+  return op_symbol_code (TREE_CODE (op), flags);
 }
 
 /* Prints the name of a call.  NODE is the CALL_EXPR_FN of a CALL_EXPR or
diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h
index 681384a8e58..2c8ee9aa377 100644
--- a/gcc/tree-pretty-print.h
+++ b/gcc/tree-pretty-print.h
@@ -49,7 +49,7 @@ extern int dump_generic_node (pretty_printer *, tree, int, 
dump_flags_t, bool);
 extern void print_declaration (pretty_printer *, tree, int, dump_flags_t);
 extern int op_code_prio (enum tree_code);
 extern int op_prio (const_tree);
-extern const char *op_symbol_code (enum tree_code);
+extern const char *op_symbol_code (enum tree_code, dump_flags_t = TDF_NONE);
 extern void pretty_print_string (pretty_printer *, const char *, size_t);
 extern void print_call_name (pretty_printer *, tree, dump_flags_t);
 extern void pp_tree_identifier (pretty_printer *, tree);
-- 
2.35.3

Reply via email to