public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 3/5] match.pd: CSE the dump output check.
@ 2023-04-28 10:39 Tamar Christina
  2023-04-28 11:49 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Tamar Christina @ 2023-04-28 10:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd, rguenther, jlaw

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

Hi All,

This is a small improvement in QoL codegen for match.pd to save time not
re-evaluating the condition for printing debug information in every function.

There is a small but consistent runtime and compile time win here.  The runtime
win comes from not having to do the condition over again, and on Arm plaforms
we now use the new test-and-branch support for booleans to only have a single
instruction here.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	PR bootstrap/84402
	* genmatch.cc (decision_tree::gen, write_predicate): Generate new
	debug_dump var.
	(dt_simplify::gen_1): Use it.

--- inline copy of patch -- 
diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index 6d62cdea2082d92e5ecc1102c80205115a4e3040..1f52ca2eebc2794159747338babb56c610387f3b 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -3431,7 +3431,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
       needs_label = true;
     }
 
-  fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & TDF_FOLDING))) "
+  fprintf_indent (f, indent, "if (UNLIKELY (debug_dump)) "
 	   "fprintf (dump_file, \"%s ",
 	   s->kind == simplify::SIMPLIFY
 	   ? "Applying pattern" : "Matching expression");
@@ -3892,6 +3892,8 @@ decision_tree::gen (FILE *f, bool gimple)
 	}
 
       fprintf (f, ")\n{\n");
+      fprintf_indent (f, 2, "const bool debug_dump = "
+			    "dump_file && (dump_flags & TDF_FOLDING);\n");
       s->s->gen_1 (f, 2, gimple, s->s->s->result);
       if (gimple)
 	fprintf (f, "  return false;\n");
@@ -3937,6 +3939,8 @@ decision_tree::gen (FILE *f, bool gimple)
 	    fprintf (f, ", tree _p%d", i);
 	  fprintf (f, ")\n");
 	  fprintf (f, "{\n");
+	  fprintf_indent (f, 2, "const bool debug_dump = "
+				"dump_file && (dump_flags & TDF_FOLDING);\n");
 	  dop->gen_kids (f, 2, gimple, 0);
 	  if (gimple)
 	    fprintf (f, "  return false;\n");
@@ -4046,6 +4050,8 @@ write_predicate (FILE *f, predicate_id *p, decision_tree &dt, bool gimple)
 	   gimple ? ", tree (*valueize)(tree) ATTRIBUTE_UNUSED" : "");
   /* Conveniently make 'type' available.  */
   fprintf_indent (f, 2, "const tree type = TREE_TYPE (t);\n");
+  fprintf_indent (f, 2, "const bool debug_dump = "
+			"dump_file && (dump_flags & TDF_FOLDING);\n");
 
   if (!gimple)
     fprintf_indent (f, 2, "if (TREE_SIDE_EFFECTS (t)) return false;\n");




-- 

[-- Attachment #2: rb17228.patch --]
[-- Type: text/plain, Size: 1721 bytes --]

diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index 6d62cdea2082d92e5ecc1102c80205115a4e3040..1f52ca2eebc2794159747338babb56c610387f3b 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -3431,7 +3431,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
       needs_label = true;
     }
 
-  fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & TDF_FOLDING))) "
+  fprintf_indent (f, indent, "if (UNLIKELY (debug_dump)) "
 	   "fprintf (dump_file, \"%s ",
 	   s->kind == simplify::SIMPLIFY
 	   ? "Applying pattern" : "Matching expression");
@@ -3892,6 +3892,8 @@ decision_tree::gen (FILE *f, bool gimple)
 	}
 
       fprintf (f, ")\n{\n");
+      fprintf_indent (f, 2, "const bool debug_dump = "
+			    "dump_file && (dump_flags & TDF_FOLDING);\n");
       s->s->gen_1 (f, 2, gimple, s->s->s->result);
       if (gimple)
 	fprintf (f, "  return false;\n");
@@ -3937,6 +3939,8 @@ decision_tree::gen (FILE *f, bool gimple)
 	    fprintf (f, ", tree _p%d", i);
 	  fprintf (f, ")\n");
 	  fprintf (f, "{\n");
+	  fprintf_indent (f, 2, "const bool debug_dump = "
+				"dump_file && (dump_flags & TDF_FOLDING);\n");
 	  dop->gen_kids (f, 2, gimple, 0);
 	  if (gimple)
 	    fprintf (f, "  return false;\n");
@@ -4046,6 +4050,8 @@ write_predicate (FILE *f, predicate_id *p, decision_tree &dt, bool gimple)
 	   gimple ? ", tree (*valueize)(tree) ATTRIBUTE_UNUSED" : "");
   /* Conveniently make 'type' available.  */
   fprintf_indent (f, 2, "const tree type = TREE_TYPE (t);\n");
+  fprintf_indent (f, 2, "const bool debug_dump = "
+			"dump_file && (dump_flags & TDF_FOLDING);\n");
 
   if (!gimple)
     fprintf_indent (f, 2, "if (TREE_SIDE_EFFECTS (t)) return false;\n");




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

* Re: [PATCH 3/5] match.pd: CSE the dump output check.
  2023-04-28 10:39 [PATCH 3/5] match.pd: CSE the dump output check Tamar Christina
@ 2023-04-28 11:49 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-04-28 11:49 UTC (permalink / raw)
  To: Tamar Christina; +Cc: gcc-patches, nd, jlaw

On Fri, 28 Apr 2023, Tamar Christina wrote:

> Hi All,
> 
> This is a small improvement in QoL codegen for match.pd to save time not
> re-evaluating the condition for printing debug information in every function.
> 
> There is a small but consistent runtime and compile time win here.  The runtime
> win comes from not having to do the condition over again, and on Arm plaforms
> we now use the new test-and-branch support for booleans to only have a single
> instruction here.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> 
> Ok for master?

OK.

Thanks,
Richard.

> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	PR bootstrap/84402
> 	* genmatch.cc (decision_tree::gen, write_predicate): Generate new
> 	debug_dump var.
> 	(dt_simplify::gen_1): Use it.
> 
> --- inline copy of patch -- 
> diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
> index 6d62cdea2082d92e5ecc1102c80205115a4e3040..1f52ca2eebc2794159747338babb56c610387f3b 100644
> --- a/gcc/genmatch.cc
> +++ b/gcc/genmatch.cc
> @@ -3431,7 +3431,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
>        needs_label = true;
>      }
>  
> -  fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & TDF_FOLDING))) "
> +  fprintf_indent (f, indent, "if (UNLIKELY (debug_dump)) "
>  	   "fprintf (dump_file, \"%s ",
>  	   s->kind == simplify::SIMPLIFY
>  	   ? "Applying pattern" : "Matching expression");
> @@ -3892,6 +3892,8 @@ decision_tree::gen (FILE *f, bool gimple)
>  	}
>  
>        fprintf (f, ")\n{\n");
> +      fprintf_indent (f, 2, "const bool debug_dump = "
> +			    "dump_file && (dump_flags & TDF_FOLDING);\n");
>        s->s->gen_1 (f, 2, gimple, s->s->s->result);
>        if (gimple)
>  	fprintf (f, "  return false;\n");
> @@ -3937,6 +3939,8 @@ decision_tree::gen (FILE *f, bool gimple)
>  	    fprintf (f, ", tree _p%d", i);
>  	  fprintf (f, ")\n");
>  	  fprintf (f, "{\n");
> +	  fprintf_indent (f, 2, "const bool debug_dump = "
> +				"dump_file && (dump_flags & TDF_FOLDING);\n");
>  	  dop->gen_kids (f, 2, gimple, 0);
>  	  if (gimple)
>  	    fprintf (f, "  return false;\n");
> @@ -4046,6 +4050,8 @@ write_predicate (FILE *f, predicate_id *p, decision_tree &dt, bool gimple)
>  	   gimple ? ", tree (*valueize)(tree) ATTRIBUTE_UNUSED" : "");
>    /* Conveniently make 'type' available.  */
>    fprintf_indent (f, 2, "const tree type = TREE_TYPE (t);\n");
> +  fprintf_indent (f, 2, "const bool debug_dump = "
> +			"dump_file && (dump_flags & TDF_FOLDING);\n");
>  
>    if (!gimple)
>      fprintf_indent (f, 2, "if (TREE_SIDE_EFFECTS (t)) return false;\n");
> 
> 
> 
> 
> 

-- 
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] 2+ messages in thread

end of thread, other threads:[~2023-04-28 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28 10:39 [PATCH 3/5] match.pd: CSE the dump output check Tamar Christina
2023-04-28 11:49 ` 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).