Avoid calling tracer.trailer() twice.

Message ID 20221010185829.312666-1-aldyh@redhat.com
State New
Headers
Series Avoid calling tracer.trailer() twice. |

Commit Message

Aldy Hernandez Oct. 10, 2022, 6:58 p.m. UTC
  [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(-)
  

Comments

Andrew MacLeod Oct. 11, 2022, 1:11 p.m. UTC | #1
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)
  
Aldy Hernandez Oct. 11, 2022, 2:08 p.m. UTC | #2
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)
>
  
Andrew MacLeod Oct. 11, 2022, 2:47 p.m. UTC | #3
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)
  

Patch

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)