public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid calling tracer.trailer() twice.
@ 2022-10-10 18:58 Aldy Hernandez
  2022-10-11 13:11 ` Andrew MacLeod
  0 siblings, 1 reply; 4+ messages in thread
From: Aldy Hernandez @ 2022-10-10 18:58 UTC (permalink / raw)
  To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez

[Andrew, you OK with this?  I can't tell whether the trailer() call was
actually needed.]

logical_combine is calling tracer.trailer() one too many times causing
the second trailer() call to subtract a 0 indent by 2, yielding an
indent of SOMETHING_REALLY_BIG :).  You'd be surprised how many tools
can't handle incredibly long lines.

gcc/ChangeLog:

	* gimple-range-gori.cc (gori_compute::logical_combine): Avoid
	calling tracer.trailer().
---
 gcc/gimple-range-gori.cc | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index b37d03cddda..469382aa477 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -798,20 +798,12 @@ gori_compute::logical_combine (vrange &r, enum tree_code code,
   // would be lost.
   if (!range_is_either_true_or_false (lhs))
     {
-      bool res;
       Value_Range r1 (r);
       if (logical_combine (r1, code, m_bool_zero, op1_true, op1_false,
 			   op2_true, op2_false)
 	  && logical_combine (r, code, m_bool_one, op1_true, op1_false,
 			      op2_true, op2_false))
-	{
-	  r.union_ (r1);
-	  res = true;
-	}
-      else
-	res = false;
-      if (idx)
-	tracer.trailer (idx, "logical_combine", res, NULL_TREE, r);
+	r.union_ (r1);
     }
 
   switch (code)
-- 
2.37.3


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

* Re: [PATCH] Avoid calling tracer.trailer() twice.
  2022-10-10 18:58 [PATCH] Avoid calling tracer.trailer() twice Aldy Hernandez
@ 2022-10-11 13:11 ` Andrew MacLeod
  2022-10-11 14:08   ` Aldy Hernandez
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew MacLeod @ 2022-10-11 13:11 UTC (permalink / raw)
  To: Aldy Hernandez, GCC patches

It probably should just be changed to a print if it doesn't return.. 
something like

if (idx && res)
   {
     tracer.print (idx, "logical_combine produced");
     r.dump (dump_file);
     fputc ('\n', dump_file);
    }

Andrew

On 10/10/22 14:58, Aldy Hernandez wrote:
> [Andrew, you OK with this?  I can't tell whether the trailer() call was
> actually needed.]
>
> logical_combine is calling tracer.trailer() one too many times causing
> the second trailer() call to subtract a 0 indent by 2, yielding an
> indent of SOMETHING_REALLY_BIG :).  You'd be surprised how many tools
> can't handle incredibly long lines.
>
> gcc/ChangeLog:
>
> 	* gimple-range-gori.cc (gori_compute::logical_combine): Avoid
> 	calling tracer.trailer().
> ---
>   gcc/gimple-range-gori.cc | 10 +---------
>   1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
> index b37d03cddda..469382aa477 100644
> --- a/gcc/gimple-range-gori.cc
> +++ b/gcc/gimple-range-gori.cc
> @@ -798,20 +798,12 @@ gori_compute::logical_combine (vrange &r, enum tree_code code,
>     // would be lost.
>     if (!range_is_either_true_or_false (lhs))
>       {
> -      bool res;
>         Value_Range r1 (r);
>         if (logical_combine (r1, code, m_bool_zero, op1_true, op1_false,
>   			   op2_true, op2_false)
>   	  && logical_combine (r, code, m_bool_one, op1_true, op1_false,
>   			      op2_true, op2_false))
> -	{
> -	  r.union_ (r1);
> -	  res = true;
> -	}
> -      else
> -	res = false;
> -      if (idx)
> -	tracer.trailer (idx, "logical_combine", res, NULL_TREE, r);
> +	r.union_ (r1);
>       }
>   
>     switch (code)


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

* Re: [PATCH] Avoid calling tracer.trailer() twice.
  2022-10-11 13:11 ` Andrew MacLeod
@ 2022-10-11 14:08   ` Aldy Hernandez
  2022-10-11 14:47     ` Andrew MacLeod
  0 siblings, 1 reply; 4+ messages in thread
From: Aldy Hernandez @ 2022-10-11 14:08 UTC (permalink / raw)
  To: Andrew MacLeod; +Cc: GCC patches

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

Sure.

OK?
Aldy

On Tue, Oct 11, 2022 at 3:11 PM Andrew MacLeod <amacleod@redhat.com> wrote:
>
> It probably should just be changed to a print if it doesn't return..
> something like
>
> if (idx && res)
>    {
>      tracer.print (idx, "logical_combine produced");
>      r.dump (dump_file);
>      fputc ('\n', dump_file);
>     }
>
> Andrew
>
> On 10/10/22 14:58, Aldy Hernandez wrote:
> > [Andrew, you OK with this?  I can't tell whether the trailer() call was
> > actually needed.]
> >
> > logical_combine is calling tracer.trailer() one too many times causing
> > the second trailer() call to subtract a 0 indent by 2, yielding an
> > indent of SOMETHING_REALLY_BIG :).  You'd be surprised how many tools
> > can't handle incredibly long lines.
> >
> > gcc/ChangeLog:
> >
> >       * gimple-range-gori.cc (gori_compute::logical_combine): Avoid
> >       calling tracer.trailer().
> > ---
> >   gcc/gimple-range-gori.cc | 10 +---------
> >   1 file changed, 1 insertion(+), 9 deletions(-)
> >
> > diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
> > index b37d03cddda..469382aa477 100644
> > --- a/gcc/gimple-range-gori.cc
> > +++ b/gcc/gimple-range-gori.cc
> > @@ -798,20 +798,12 @@ gori_compute::logical_combine (vrange &r, enum tree_code code,
> >     // would be lost.
> >     if (!range_is_either_true_or_false (lhs))
> >       {
> > -      bool res;
> >         Value_Range r1 (r);
> >         if (logical_combine (r1, code, m_bool_zero, op1_true, op1_false,
> >                          op2_true, op2_false)
> >         && logical_combine (r, code, m_bool_one, op1_true, op1_false,
> >                             op2_true, op2_false))
> > -     {
> > -       r.union_ (r1);
> > -       res = true;
> > -     }
> > -      else
> > -     res = false;
> > -      if (idx)
> > -     tracer.trailer (idx, "logical_combine", res, NULL_TREE, r);
> > +     r.union_ (r1);
> >       }
> >
> >     switch (code)
>

[-- Attachment #2: 0001-Avoid-calling-tracer.trailer-twice.patch --]
[-- Type: text/x-patch, Size: 951 bytes --]

From e7fb4679528d190463cf3d0d4a4daa7333b5a553 Mon Sep 17 00:00:00 2001
From: Aldy Hernandez <aldyh@redhat.com>
Date: Tue, 11 Oct 2022 16:00:33 +0200
Subject: [PATCH] Avoid calling tracer.trailer() twice.

gcc/ChangeLog:

        * gimple-range-gori.cc (gori_compute::logical_combine): Avoid
        calling tracer.trailer().
---
 gcc/gimple-range-gori.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index b37d03cddda..5ff067cadb5 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -810,8 +810,12 @@ gori_compute::logical_combine (vrange &r, enum tree_code code,
 	}
       else
 	res = false;
-      if (idx)
-	tracer.trailer (idx, "logical_combine", res, NULL_TREE, r);
+      if (idx && res)
+	{
+	  tracer.print (idx, "logical_combine produced ");
+	  r.dump (dump_file);
+	  fputc ('\n', dump_file);
+	}
     }
 
   switch (code)
-- 
2.37.3


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

* Re: [PATCH] Avoid calling tracer.trailer() twice.
  2022-10-11 14:08   ` Aldy Hernandez
@ 2022-10-11 14:47     ` Andrew MacLeod
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew MacLeod @ 2022-10-11 14:47 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: GCC patches

perfect.

On 10/11/22 10:08, Aldy Hernandez wrote:
> Sure.
>
> OK?
> Aldy
>
> On Tue, Oct 11, 2022 at 3:11 PM Andrew MacLeod <amacleod@redhat.com> wrote:
>> It probably should just be changed to a print if it doesn't return..
>> something like
>>
>> if (idx && res)
>>     {
>>       tracer.print (idx, "logical_combine produced");
>>       r.dump (dump_file);
>>       fputc ('\n', dump_file);
>>      }
>>
>> Andrew
>>
>> On 10/10/22 14:58, Aldy Hernandez wrote:
>>> [Andrew, you OK with this?  I can't tell whether the trailer() call was
>>> actually needed.]
>>>
>>> logical_combine is calling tracer.trailer() one too many times causing
>>> the second trailer() call to subtract a 0 indent by 2, yielding an
>>> indent of SOMETHING_REALLY_BIG :).  You'd be surprised how many tools
>>> can't handle incredibly long lines.
>>>
>>> gcc/ChangeLog:
>>>
>>>        * gimple-range-gori.cc (gori_compute::logical_combine): Avoid
>>>        calling tracer.trailer().
>>> ---
>>>    gcc/gimple-range-gori.cc | 10 +---------
>>>    1 file changed, 1 insertion(+), 9 deletions(-)
>>>
>>> diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
>>> index b37d03cddda..469382aa477 100644
>>> --- a/gcc/gimple-range-gori.cc
>>> +++ b/gcc/gimple-range-gori.cc
>>> @@ -798,20 +798,12 @@ gori_compute::logical_combine (vrange &r, enum tree_code code,
>>>      // would be lost.
>>>      if (!range_is_either_true_or_false (lhs))
>>>        {
>>> -      bool res;
>>>          Value_Range r1 (r);
>>>          if (logical_combine (r1, code, m_bool_zero, op1_true, op1_false,
>>>                           op2_true, op2_false)
>>>          && logical_combine (r, code, m_bool_one, op1_true, op1_false,
>>>                              op2_true, op2_false))
>>> -     {
>>> -       r.union_ (r1);
>>> -       res = true;
>>> -     }
>>> -      else
>>> -     res = false;
>>> -      if (idx)
>>> -     tracer.trailer (idx, "logical_combine", res, NULL_TREE, r);
>>> +     r.union_ (r1);
>>>        }
>>>
>>>      switch (code)


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

end of thread, other threads:[~2022-10-11 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 18:58 [PATCH] Avoid calling tracer.trailer() twice Aldy Hernandez
2022-10-11 13:11 ` Andrew MacLeod
2022-10-11 14:08   ` Aldy Hernandez
2022-10-11 14:47     ` Andrew MacLeod

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