public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Kai Tietz <ktietz70@googlemail.com>
Cc: Paolo Bonzini <bonzini@gnu.org>, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch tree-optimization]: [3 of 3]: Boolify compares & more
Date: Fri, 08 Jul 2011 14:57:00 -0000	[thread overview]
Message-ID: <CAFiYyc1xRQ1daxNpCjy3z+DQJspkviS5bF0WukKBn+d8mc3A0w@mail.gmail.com> (raw)
In-Reply-To: <CAEwic4Z3+joLSkgPh-ZD_d_FsW8BujMPjH03jw0Xrq=7cTyE9w@mail.gmail.com>

On Fri, Jul 8, 2011 at 4:35 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 2011/7/8 Richard Guenther <richard.guenther@gmail.com>:
>> On Thu, Jul 7, 2011 at 6:28 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> 2011/7/7 Paolo Bonzini <bonzini@gnu.org>:
>>>> On 07/07/2011 06:07 PM, Kai Tietz wrote:
>>>>>
>>>>> +  /* We redo folding here one time for allowing to inspect more
>>>>> +     complex reductions.  */
>>>>> +  substitute_and_fold (op_with_constant_singleton_value_range,
>>>>> +                      vrp_fold_stmt, false);
>>>>> +  /* We need to mark this second pass to avoid re-entering of same
>>>>> +     edges for switch statments.  */
>>>>> +  in_second_pass = true;
>>>>>    substitute_and_fold (op_with_constant_singleton_value_range,
>>>>>                       vrp_fold_stmt, false);
>>>>> +  in_second_pass = false;
>>>>
>>>> This needs a much better explanation.
>>>>
>>>> Paolo
>>>
>>> Well, I can work on a better comment.  The complex reduction I mean
>>> here are cases like
>>>
>>> int x;
>>> int y;
>>> _Bool D1;
>>> _Bool D2;
>>> _Bool D3;
>>> int R;
>>>
>>> D1 = x[0..1] != 0;
>>> D2 = y[0..1] != 0;
>>> D3 = D1 & D2
>>> R = (int) D3
>>>
>>> (testcase is already present. See tree-ssa/vrp47.c).
>>>
>>> As VRP in first pass produces (and replaces) to:
>>>
>>> D1 = (_Bool) x[0..1];
>>> D2 = (_Bool) y[0..1];
>>> D3 = D1 & D2
>>> R = (int) D3
>>>
>>> Just in the second pass the reduction
>>>
>>> R = x[0..1] & y[0..1]
>>
>> So why wouldn't that happen during the first pass?  The first
>> pass could change the IL to
>>
>>  D1 = x[0..1] != 0;
>>  D2 = y[0..1] != 0;
>>  D3 = D1 & D2;
>>  R = x & y;
>>
>> if D3 only has a single use.
> No, as D3 would need a type change, and this isn't possible.  If it
> wasn't absolutely clear, this patch to VRP is necessary after patch 2,
> as here D1, D2, and D3 have bool-type, and just R is of type int.

In your example x,y and R are int, so it works with re-using R.

>>> can happen.  In general it is sad that VRP can't insert during pass
>>> new statements right now.  This would cause issues in range-tables,
>>> which aren't designed for insertations.  As otherwise, we could do
>>> also simplify things like
>>>
>>> D1 = x[0..1] != 0;
>>> D2 = y[0..1] == 0;
>>> D3 = D1 & D2
>>> R = (int) D3
>>>
>>> to
>>> R = x[0..1] & (y[0..1] ^ 1)
>>
>> Why that ^ 1?  And why does that confuse the range tables
>> if you re-use R?
> Because we would need to insert a new statement and this isn't allowed
> in VRP. See the comments in VRP and substitute_and_fold.  VRP
> disallows to remove statements or to insert new ones.

That's not a hard limitation.

>>> Regards,
>>> Kai
>

  reply	other threads:[~2011-07-08 14:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-07 16:14 Kai Tietz
2011-07-07 16:19 ` Paolo Bonzini
2011-07-07 16:28   ` Kai Tietz
2011-07-08  9:45     ` Richard Guenther
2011-07-08 10:59       ` Kai Tietz
2011-07-08 11:08       ` Kai Tietz
2011-07-08 14:40       ` Kai Tietz
2011-07-08 14:57         ` Richard Guenther [this message]
2011-07-08 15:05           ` Kai Tietz
2011-07-08  9:39 ` Richard Guenther
2011-07-08 15:49   ` Kai Tietz
2011-07-08 16:31     ` Kai Tietz
2011-07-08 16:45       ` Michael Matz
2011-07-08 17:26         ` Kai Tietz
2011-07-12 17:18           ` Kai Tietz
2011-07-13 11:06             ` Richard Guenther
2011-07-15  7:59               ` Kai Tietz
2011-07-19 12:24                 ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc1xRQ1daxNpCjy3z+DQJspkviS5bF0WukKBn+d8mc3A0w@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=bonzini@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ktietz70@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).