diff mbox

Print repeated rtl vector elements in a nicer way

Message ID 20161103163514.eg5rdeev7eic5svc@virgil.suse.cz
State New
Headers show

Commit Message

Martin Jambor Nov. 3, 2016, 4:35 p.m. UTC
Hi,

this patch comes from our GCN BE branch.  Because vectors of that
architectures have many elements, RTL dumps can get quite unwieldy when
all elements are printed out all the time.  However, pretty much all the
time it is the same value repeated over and over again, which lead us to
the following patch which just prints how many times a given value
occurs.

Honza has asked me yesterday to submit this hunk upstream so here it
is.  It has passed bootstrap and testing on x86_64-linux and
aarch64-linux, OK for trunk?

Thanks,

Martin


2016-11-02  Jan Hubicka  <jh@suse.cz>
	    Martin Jambor  <mjambor@suse.cz>

	* print-rtl.c (print_rtx_operand_codes_E_and_V): Print how many times
	an element is repeated istead of printing each repeated element.
---
 gcc/print-rtl.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Bernd Schmidt Nov. 3, 2016, 4:43 p.m. UTC | #1
On 11/03/2016 05:35 PM, Martin Jambor wrote:
>
> 	* print-rtl.c (print_rtx_operand_codes_E_and_V): Print how many times
> 	an element is repeated istead of printing each repeated element.

"instead"

> ---
>  gcc/print-rtl.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> index 341ecdf..9752c85 100644
> --- a/gcc/print-rtl.c
> +++ b/gcc/print-rtl.c
> @@ -252,7 +252,20 @@ rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx)
>  	m_sawclose = 1;
>
>        for (int j = 0; j < XVECLEN (in_rtx, idx); j++)
> -	print_rtx (XVECEXP (in_rtx, idx, j));
> +	{
> +	  int j1;
> +
> +	  print_rtx (XVECEXP (in_rtx, idx, j));
> +	  for (j1 = j + 1; j1 < XVECLEN (in_rtx, idx); j1++)
> +	    if (XVECEXP (in_rtx, idx, j) != XVECEXP (in_rtx, idx, j1))
> +	      break;
> +
> +	  if (j1 != j + 1)
> +	    {
> +	      fprintf (m_outfile, " repeated %ix", j1 - j);
> +	      j = j1;
> +	    }
> +	}

Good idea, but can you give an example of how this looks in practice? 
Also, it would be nice (and necessary for David's rtl-testing) to also 
teach the rtl reader to parse this format.


Bernd
David Malcolm Nov. 3, 2016, 7:36 p.m. UTC | #2
On Thu, 2016-11-03 at 17:43 +0100, Bernd Schmidt wrote:
> On 11/03/2016 05:35 PM, Martin Jambor wrote:
> > 
> > 	* print-rtl.c (print_rtx_operand_codes_E_and_V): Print how many
> > times
> > 	an element is repeated istead of printing each repeated
> > element.
> 
> "instead"
> 
> > ---
> >  gcc/print-rtl.c | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> > index 341ecdf..9752c85 100644
> > --- a/gcc/print-rtl.c
> > +++ b/gcc/print-rtl.c
> > @@ -252,7 +252,20 @@ rtx_writer::print_rtx_operand_codes_E_and_V
> > (const_rtx in_rtx, int idx)
> >  	m_sawclose = 1;
> > 
> >        for (int j = 0; j < XVECLEN (in_rtx, idx); j++)
> > -	print_rtx (XVECEXP (in_rtx, idx, j));
> > +	{
> > +	  int j1;
> > +
> > +	  print_rtx (XVECEXP (in_rtx, idx, j));
> > +	  for (j1 = j + 1; j1 < XVECLEN (in_rtx, idx); j1++)
> > +	    if (XVECEXP (in_rtx, idx, j) != XVECEXP (in_rtx, idx,
> > j1))
> > +	      break;
> > +
> > +	  if (j1 != j + 1)
> > +	    {
> > +	      fprintf (m_outfile, " repeated %ix", j1 - j);
> > +	      j = j1;
> > +	    }
> > +	}
> Good idea, but can you give an example of how this looks in practice?

It should be possible to create a simple selftest of this (for pre
-existing examples, look for ASSERT_RTL_DUMP_EQ in gcc/rtl-tests.c).

> Also, it would be nice (and necessary for David's rtl-testing) to
> also 
>  
> teach the rtl reader to parse this format.

Yes please, ideally with a selftest, though that may be tricky until
the rtl-testing work goes in.

(I suppose it could be disabled in compact mode, but that seems to be
an abuse of the term "compact").
Martin Jambor Nov. 4, 2016, 6:23 p.m. UTC | #3
On Thu, Nov 03, 2016 at 05:43:50PM +0100, Bernd Schmidt wrote:
> On 11/03/2016 05:35 PM, Martin Jambor wrote:
> > 
> > 	* print-rtl.c (print_rtx_operand_codes_E_and_V): Print how many times
> > 	an element is repeated istead of printing each repeated element.
> 
> "instead"

Will fix.

> 
> > ---
> >  gcc/print-rtl.c | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> > index 341ecdf..9752c85 100644
> > --- a/gcc/print-rtl.c
> > +++ b/gcc/print-rtl.c
> > @@ -252,7 +252,20 @@ rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx)
> >  	m_sawclose = 1;
> > 
> >        for (int j = 0; j < XVECLEN (in_rtx, idx); j++)
> > -	print_rtx (XVECEXP (in_rtx, idx, j));
> > +	{
> > +	  int j1;
> > +
> > +	  print_rtx (XVECEXP (in_rtx, idx, j));
> > +	  for (j1 = j + 1; j1 < XVECLEN (in_rtx, idx); j1++)
> > +	    if (XVECEXP (in_rtx, idx, j) != XVECEXP (in_rtx, idx, j1))
> > +	      break;
> > +
> > +	  if (j1 != j + 1)
> > +	    {
> > +	      fprintf (m_outfile, " repeated %ix", j1 - j);
> > +	      j = j1;
> > +	    }
> > +	}
> 
> Good idea, but can you give an example of how this looks in
> practice?

For example, after the patch dumps of constant vectors look like this:

(insn 27 26 28 2 (set (reg:V64SI 450)
        (vec_merge:V64SI (ashift:V64SI (reg/v:V64SI 433 [ workitem_id ])
                (const_vector:V64SI [
                        (const_int 2 [0x2]) repeated 64x
                    ]))
            (unspec:V64SI [
                    (const_int 0 [0])
                ] UNSPEC_VECTOR)
            (reg:DI 425 [ exec.1_4 ]))) "kernel.c":35 -1
     (nil))

Without it, the very same insn is printed as following:

(insn 27 26 28 2 (set (reg:V64SI 450)
        (vec_merge:V64SI (ashift:V64SI (reg/v:V64SI 433 [ workitem_id ])
                (const_vector:V64SI [
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                        (const_int 2 [0x2])
                    ]))
            (unspec:V64SI [
                    (const_int 0 [0])
                ] UNSPEC_VECTOR)
            (reg:DI 425 [ exec.1_4 ]))) "kernel.c":35 -1
     (nil))

> Also,
> it would be nice (and necessary for David's rtl-testing) to also teach the
> rtl reader to parse this format.
> 

I see, thanks for the pointer, I will have a look at it, although I
may not make it soon enough for gcc 7.

Martin
diff mbox

Patch

diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index 341ecdf..9752c85 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -252,7 +252,20 @@  rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx)
 	m_sawclose = 1;
 
       for (int j = 0; j < XVECLEN (in_rtx, idx); j++)
-	print_rtx (XVECEXP (in_rtx, idx, j));
+	{
+	  int j1;
+
+	  print_rtx (XVECEXP (in_rtx, idx, j));
+	  for (j1 = j + 1; j1 < XVECLEN (in_rtx, idx); j1++)
+	    if (XVECEXP (in_rtx, idx, j) != XVECEXP (in_rtx, idx, j1))
+	      break;
+
+	  if (j1 != j + 1)
+	    {
+	      fprintf (m_outfile, " repeated %ix", j1 - j);
+	      j = j1;
+	    }
+	}
 
       m_indent -= 2;
     }