public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add dbgcnt for gimple_match and generic_match.
@ 2019-07-03 10:39 Martin Liška
  2019-07-03 11:49 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Liška @ 2019-07-03 10:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Biener

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

Hi.

The patch is about dbgcnt support for match in GIMPLE and GENERIC.
It's handy for isolation of a problem.

Ready to be installed after it survives tests?
Thanks,
Martin

gcc/ChangeLog:

2019-07-03  Martin Liska  <mliska@suse.cz>

	* dbgcnt.def (DEBUG_COUNTER): Add gimple_match and
	generic_match.
	* genmatch.c (dt_simplify::gen_1): Generate dbgcnt
	condition.
	* generic-match-head.c: Include dbgcnt.h.
	* gimple-match-head.c: Likewise.
---
 gcc/dbgcnt.def           | 2 ++
 gcc/generic-match-head.c | 2 +-
 gcc/genmatch.c           | 5 +++++
 gcc/gimple-match-head.c  | 2 +-
 4 files changed, 9 insertions(+), 2 deletions(-)



[-- Attachment #2: 0001-Add-dbgcnt-for-gimple_match-and-generic_match.patch --]
[-- Type: text/x-patch, Size: 1882 bytes --]

diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def
index dd874c519bb..7ab32816a05 100644
--- a/gcc/dbgcnt.def
+++ b/gcc/dbgcnt.def
@@ -195,3 +195,5 @@ DEBUG_COUNTER (tree_sra)
 DEBUG_COUNTER (vect_loop)
 DEBUG_COUNTER (vect_slp)
 DEBUG_COUNTER (dom_unreachable_edges)
+DEBUG_COUNTER (gimple_match)
+DEBUG_COUNTER (generic_match)
diff --git a/gcc/generic-match-head.c b/gcc/generic-match-head.c
index 76fc9993481..b54e03552ba 100644
--- a/gcc/generic-match-head.c
+++ b/gcc/generic-match-head.c
@@ -35,7 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "case-cfn-macros.h"
 #include "gimplify.h"
 #include "optabs-tree.h"
-
+#include "dbgcnt.h"
 
 /* Routine to determine if the types T1 and T2 are effectively
    the same for GENERIC.  If T1 or T2 is not a type, the test
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 7b9b09c7d8b..8ec73f82482 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -3310,6 +3310,11 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
 	}
     }
 
+  if (gimple)
+    fprintf_indent (f, indent, "if (__builtin_expect (!dbg_cnt (gimple_match), 0)) return false;\n");
+  else
+    fprintf_indent (f, indent, "if (__builtin_expect (!dbg_cnt (generic_match), 0)) return NULL_TREE;\n");
+
   fprintf_indent (f, indent, "if (__builtin_expect (dump_file && (dump_flags & TDF_FOLDING), 0)) "
 	   "fprintf (dump_file, \"%s ",
 	   s->kind == simplify::SIMPLIFY
diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c
index f83f2256178..df9f0c50590 100644
--- a/gcc/gimple-match-head.c
+++ b/gcc/gimple-match-head.c
@@ -42,7 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "optabs-tree.h"
 #include "tree-eh.h"
-
+#include "dbgcnt.h"
 
 /* Forward declarations of the private auto-generated matchers.
    They expect valueized operands in canonical order and do not


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

* Re: [PATCH] Add dbgcnt for gimple_match and generic_match.
  2019-07-03 10:39 [PATCH] Add dbgcnt for gimple_match and generic_match Martin Liška
@ 2019-07-03 11:49 ` Richard Biener
  2019-07-03 12:39   ` Martin Liška
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2019-07-03 11:49 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches

On Wed, Jul 3, 2019 at 12:39 PM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> The patch is about dbgcnt support for match in GIMPLE and GENERIC.
> It's handy for isolation of a problem.
>
> Ready to be installed after it survives tests?

Hmm, I think we only want this on (simplify...), not (match...), no?
Thus simply move the code into the preceeding if() body.

I'd also merge gimple and generic_match counters since passes
happen to use both.

OK with that changes.
Richard.

> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2019-07-03  Martin Liska  <mliska@suse.cz>
>
>         * dbgcnt.def (DEBUG_COUNTER): Add gimple_match and
>         generic_match.
>         * genmatch.c (dt_simplify::gen_1): Generate dbgcnt
>         condition.
>         * generic-match-head.c: Include dbgcnt.h.
>         * gimple-match-head.c: Likewise.
> ---
>  gcc/dbgcnt.def           | 2 ++
>  gcc/generic-match-head.c | 2 +-
>  gcc/genmatch.c           | 5 +++++
>  gcc/gimple-match-head.c  | 2 +-
>  4 files changed, 9 insertions(+), 2 deletions(-)
>
>

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

* Re: [PATCH] Add dbgcnt for gimple_match and generic_match.
  2019-07-03 11:49 ` Richard Biener
@ 2019-07-03 12:39   ` Martin Liška
  2019-07-03 12:41     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Liška @ 2019-07-03 12:39 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

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

On 7/3/19 1:48 PM, Richard Biener wrote:
> On Wed, Jul 3, 2019 at 12:39 PM Martin Liška <mliska@suse.cz> wrote:
>>
>> Hi.
>>
>> The patch is about dbgcnt support for match in GIMPLE and GENERIC.
>> It's handy for isolation of a problem.
>>
>> Ready to be installed after it survives tests?
> 
> Hmm, I think we only want this on (simplify...), not (match...), no?
> Thus simply move the code into the preceeding if() body.

I've done that with s->kind == simplify::SIMPLIFY. Would it be fine?

> 
> I'd also merge gimple and generic_match counters since passes
> happen to use both.

Works for me.

Martin

> 
> OK with that changes.
> Richard.
> 
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2019-07-03  Martin Liska  <mliska@suse.cz>
>>
>>         * dbgcnt.def (DEBUG_COUNTER): Add gimple_match and
>>         generic_match.
>>         * genmatch.c (dt_simplify::gen_1): Generate dbgcnt
>>         condition.
>>         * generic-match-head.c: Include dbgcnt.h.
>>         * gimple-match-head.c: Likewise.
>> ---
>>  gcc/dbgcnt.def           | 2 ++
>>  gcc/generic-match-head.c | 2 +-
>>  gcc/genmatch.c           | 5 +++++
>>  gcc/gimple-match-head.c  | 2 +-
>>  4 files changed, 9 insertions(+), 2 deletions(-)
>>
>>


[-- Attachment #2: 0001-Add-dbgcnt-for-gimple_match-and-generic_match.patch --]
[-- Type: text/x-patch, Size: 2445 bytes --]

From 035a918ba10ad002ef1707e308143040311f707b Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 3 Jul 2019 12:37:06 +0200
Subject: [PATCH] Add dbgcnt for gimple_match and generic_match.

gcc/ChangeLog:

2019-07-03  Martin Liska  <mliska@suse.cz>

	* dbgcnt.def (DEBUG_COUNTER): Add match debug counter.
	* genmatch.c (dt_simplify::gen_1): Generate dbgcnt
	condition.
	* generic-match-head.c: Include dbgcnt.h.
	* gimple-match-head.c: Likewise.
---
 gcc/dbgcnt.def           | 1 +
 gcc/generic-match-head.c | 2 +-
 gcc/genmatch.c           | 4 ++++
 gcc/gimple-match-head.c  | 2 +-
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def
index dd874c519bb..230072f7bb5 100644
--- a/gcc/dbgcnt.def
+++ b/gcc/dbgcnt.def
@@ -195,3 +195,4 @@ DEBUG_COUNTER (tree_sra)
 DEBUG_COUNTER (vect_loop)
 DEBUG_COUNTER (vect_slp)
 DEBUG_COUNTER (dom_unreachable_edges)
+DEBUG_COUNTER (match)
diff --git a/gcc/generic-match-head.c b/gcc/generic-match-head.c
index 76fc9993481..b54e03552ba 100644
--- a/gcc/generic-match-head.c
+++ b/gcc/generic-match-head.c
@@ -35,7 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "case-cfn-macros.h"
 #include "gimplify.h"
 #include "optabs-tree.h"
-
+#include "dbgcnt.h"
 
 /* Routine to determine if the types T1 and T2 are effectively
    the same for GENERIC.  If T1 or T2 is not a type, the test
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 7b9b09c7d8b..109bd9e6f2d 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -3310,6 +3310,10 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
 	}
     }
 
+  if (s->kind == simplify::SIMPLIFY)
+    fprintf_indent (f, indent, "if (__builtin_expect (!dbg_cnt (match), 0)) return %s;\n",
+		    gimple ? "false" : "NULL_TREE");
+
   fprintf_indent (f, indent, "if (__builtin_expect (dump_file && (dump_flags & TDF_FOLDING), 0)) "
 	   "fprintf (dump_file, \"%s ",
 	   s->kind == simplify::SIMPLIFY
diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c
index f83f2256178..df9f0c50590 100644
--- a/gcc/gimple-match-head.c
+++ b/gcc/gimple-match-head.c
@@ -42,7 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "optabs-tree.h"
 #include "tree-eh.h"
-
+#include "dbgcnt.h"
 
 /* Forward declarations of the private auto-generated matchers.
    They expect valueized operands in canonical order and do not
-- 
2.22.0


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

* Re: [PATCH] Add dbgcnt for gimple_match and generic_match.
  2019-07-03 12:39   ` Martin Liška
@ 2019-07-03 12:41     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2019-07-03 12:41 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches

On Wed, Jul 3, 2019 at 2:39 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 7/3/19 1:48 PM, Richard Biener wrote:
> > On Wed, Jul 3, 2019 at 12:39 PM Martin Liška <mliska@suse.cz> wrote:
> >>
> >> Hi.
> >>
> >> The patch is about dbgcnt support for match in GIMPLE and GENERIC.
> >> It's handy for isolation of a problem.
> >>
> >> Ready to be installed after it survives tests?
> >
> > Hmm, I think we only want this on (simplify...), not (match...), no?
> > Thus simply move the code into the preceeding if() body.
>
> I've done that with s->kind == simplify::SIMPLIFY. Would it be fine?
>
> >
> > I'd also merge gimple and generic_match counters since passes
> > happen to use both.
>
> Works for me.

OK.

Thanks,
Richard.

> Martin
>
> >
> > OK with that changes.
> > Richard.
> >
> >> Thanks,
> >> Martin
> >>
> >> gcc/ChangeLog:
> >>
> >> 2019-07-03  Martin Liska  <mliska@suse.cz>
> >>
> >>         * dbgcnt.def (DEBUG_COUNTER): Add gimple_match and
> >>         generic_match.
> >>         * genmatch.c (dt_simplify::gen_1): Generate dbgcnt
> >>         condition.
> >>         * generic-match-head.c: Include dbgcnt.h.
> >>         * gimple-match-head.c: Likewise.
> >> ---
> >>  gcc/dbgcnt.def           | 2 ++
> >>  gcc/generic-match-head.c | 2 +-
> >>  gcc/genmatch.c           | 5 +++++
> >>  gcc/gimple-match-head.c  | 2 +-
> >>  4 files changed, 9 insertions(+), 2 deletions(-)
> >>
> >>
>

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

end of thread, other threads:[~2019-07-03 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 10:39 [PATCH] Add dbgcnt for gimple_match and generic_match Martin Liška
2019-07-03 11:49 ` Richard Biener
2019-07-03 12:39   ` Martin Liška
2019-07-03 12:41     ` 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).