public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove GENERIC expr building from predicate analysis, improve dumps
@ 2022-08-30 10:38 Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-08-30 10:38 UTC (permalink / raw)
  To: gcc-patches

The following removes duplicate dumping and makes the predicate
dumping more readable.  That makes the GENERIC predicate build
routines unused which is also nice.

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

	* gimple-predicate-analysis.cc (dump_pred_chain): Fix
	parentizing and AND prepending.
	(predicate::dump): Do not dump the GENERIC expanded
	predicate, properly parentize and prepend ORs to the
	piecewise predicate dump.
	(build_pred_expr): Remove.
---
 gcc/gimple-predicate-analysis.cc | 77 +++++---------------------------
 1 file changed, 10 insertions(+), 67 deletions(-)

diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
index dcecbb5a581..ffdd8a15fe7 100644
--- a/gcc/gimple-predicate-analysis.cc
+++ b/gcc/gimple-predicate-analysis.cc
@@ -169,16 +169,14 @@ static void
 dump_pred_chain (const pred_chain &chain)
 {
   unsigned np = chain.length ();
-  if (np > 1)
-    fprintf (dump_file, "AND (");
-
   for (unsigned j = 0; j < np; j++)
     {
+      if (j > 0)
+	fprintf (dump_file, " AND (");
+      else
+	fputc ('(', dump_file);
       dump_pred_info (chain[j]);
-      if (j < np - 1)
-	fprintf (dump_file, ", ");
-      else if (j > 0)
-	fputc (')', dump_file);
+      fputc (')', dump_file);
     }
 }
 
@@ -579,51 +577,6 @@ uninit_analysis::collect_phi_def_edges (gphi *phi, basic_block cd_root,
     }
 }
 
-/* Return an expression corresponding to the predicate PRED.  */
-
-static tree
-build_pred_expr (const pred_info &pred)
-{
-  tree_code cond_code = pred.cond_code;
-  tree lhs = pred.pred_lhs;
-  tree rhs = pred.pred_rhs;
-
-  if (pred.invert)
-    cond_code = invert_tree_comparison (cond_code, false);
-
-  return build2 (cond_code, TREE_TYPE (lhs), lhs, rhs);
-}
-
-/* Return an expression corresponding to PREDS.  */
-
-static tree
-build_pred_expr (const pred_chain_union &preds, bool invert = false)
-{
-  tree_code code = invert ? TRUTH_AND_EXPR : TRUTH_OR_EXPR;
-  tree_code subcode = invert ? TRUTH_OR_EXPR : TRUTH_AND_EXPR;
-
-  tree expr = NULL_TREE;
-  for (unsigned i = 0; i != preds.length (); ++i)
-    {
-      tree subexpr = NULL_TREE;
-      for (unsigned j = 0; j != preds[i].length (); ++j)
-       {
-         const pred_info &pi = preds[i][j];
-         tree cond = build_pred_expr (pi);
-	 if (invert)
-	   cond = invert_truthvalue (cond);
-         subexpr = subexpr ? build2 (subcode, boolean_type_node,
-                                     subexpr, cond) : cond;
-       }
-      if (expr)
-       expr = build2 (code, boolean_type_node, expr, subexpr);
-      else
-       expr = subexpr;
-    }
-
-  return expr;
-}
-
 /* Return a bitset of all PHI arguments or zero if there are too many.  */
 
 unsigned
@@ -1907,24 +1860,14 @@ predicate::dump (gimple *stmt, const char *msg) const
       return;
     }
 
-  {
-    tree expr = build_pred_expr (m_preds);
-    char *str = print_generic_expr_to_str (expr);
-    fprintf (dump_file, "\t%s (expanded)\n", str);
-    free (str);
-  }
-
-  if (np > 1)
-    fprintf (dump_file, "\tOR (");
-  else
-    fputc ('\t', dump_file);
   for (unsigned i = 0; i < np; i++)
     {
+      if (i > 0)
+	fprintf (dump_file, "\tOR (");
+      else
+	fprintf (dump_file, "\t(");
       dump_pred_chain (m_preds[i]);
-      if (i < np - 1)
-	fprintf (dump_file, ", ");
-      else if (i > 0)
-	fputc (')', dump_file);
+      fputc (')', dump_file);
     }
   fputc ('\n', dump_file);
 }
-- 
2.35.3

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

* [PATCH] Remove GENERIC expr building from predicate analysis, improve dumps
@ 2022-08-30 10:38 Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-08-30 10:38 UTC (permalink / raw)
  To: gcc-patches

The following removes duplicate dumping and makes the predicate
dumping more readable.  That makes the GENERIC predicate build
routines unused which is also nice.

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

	* gimple-predicate-analysis.cc (dump_pred_chain): Fix
	parentizing and AND prepending.
	(predicate::dump): Do not dump the GENERIC expanded
	predicate, properly parentize and prepend ORs to the
	piecewise predicate dump.
	(build_pred_expr): Remove.
---
 gcc/gimple-predicate-analysis.cc | 77 +++++---------------------------
 1 file changed, 10 insertions(+), 67 deletions(-)

diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
index dcecbb5a581..ffdd8a15fe7 100644
--- a/gcc/gimple-predicate-analysis.cc
+++ b/gcc/gimple-predicate-analysis.cc
@@ -169,16 +169,14 @@ static void
 dump_pred_chain (const pred_chain &chain)
 {
   unsigned np = chain.length ();
-  if (np > 1)
-    fprintf (dump_file, "AND (");
-
   for (unsigned j = 0; j < np; j++)
     {
+      if (j > 0)
+	fprintf (dump_file, " AND (");
+      else
+	fputc ('(', dump_file);
       dump_pred_info (chain[j]);
-      if (j < np - 1)
-	fprintf (dump_file, ", ");
-      else if (j > 0)
-	fputc (')', dump_file);
+      fputc (')', dump_file);
     }
 }
 
@@ -579,51 +577,6 @@ uninit_analysis::collect_phi_def_edges (gphi *phi, basic_block cd_root,
     }
 }
 
-/* Return an expression corresponding to the predicate PRED.  */
-
-static tree
-build_pred_expr (const pred_info &pred)
-{
-  tree_code cond_code = pred.cond_code;
-  tree lhs = pred.pred_lhs;
-  tree rhs = pred.pred_rhs;
-
-  if (pred.invert)
-    cond_code = invert_tree_comparison (cond_code, false);
-
-  return build2 (cond_code, TREE_TYPE (lhs), lhs, rhs);
-}
-
-/* Return an expression corresponding to PREDS.  */
-
-static tree
-build_pred_expr (const pred_chain_union &preds, bool invert = false)
-{
-  tree_code code = invert ? TRUTH_AND_EXPR : TRUTH_OR_EXPR;
-  tree_code subcode = invert ? TRUTH_OR_EXPR : TRUTH_AND_EXPR;
-
-  tree expr = NULL_TREE;
-  for (unsigned i = 0; i != preds.length (); ++i)
-    {
-      tree subexpr = NULL_TREE;
-      for (unsigned j = 0; j != preds[i].length (); ++j)
-       {
-         const pred_info &pi = preds[i][j];
-         tree cond = build_pred_expr (pi);
-	 if (invert)
-	   cond = invert_truthvalue (cond);
-         subexpr = subexpr ? build2 (subcode, boolean_type_node,
-                                     subexpr, cond) : cond;
-       }
-      if (expr)
-       expr = build2 (code, boolean_type_node, expr, subexpr);
-      else
-       expr = subexpr;
-    }
-
-  return expr;
-}
-
 /* Return a bitset of all PHI arguments or zero if there are too many.  */
 
 unsigned
@@ -1907,24 +1860,14 @@ predicate::dump (gimple *stmt, const char *msg) const
       return;
     }
 
-  {
-    tree expr = build_pred_expr (m_preds);
-    char *str = print_generic_expr_to_str (expr);
-    fprintf (dump_file, "\t%s (expanded)\n", str);
-    free (str);
-  }
-
-  if (np > 1)
-    fprintf (dump_file, "\tOR (");
-  else
-    fputc ('\t', dump_file);
   for (unsigned i = 0; i < np; i++)
     {
+      if (i > 0)
+	fprintf (dump_file, "\tOR (");
+      else
+	fprintf (dump_file, "\t(");
       dump_pred_chain (m_preds[i]);
-      if (i < np - 1)
-	fprintf (dump_file, ", ");
-      else if (i > 0)
-	fputc (')', dump_file);
+      fputc (')', dump_file);
     }
   fputc ('\n', dump_file);
 }
-- 
2.35.3

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

end of thread, other threads:[~2022-08-30 10:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30 10:38 [PATCH] Remove GENERIC expr building from predicate analysis, improve dumps Richard Biener
2022-08-30 10:38 Richard Biener

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).