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: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch tree-ssa-reassoc.c]: Better reassoication for comparision and boolean-logic
Date: Sat, 21 May 2011 16:17:00 -0000	[thread overview]
Message-ID: <BANLkTikrF3rF6uM5FVsDeas=TdjvWGJgGA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTinQatKOZg4Kb9J0Q5-BYTKnpXp3Qg@mail.gmail.com>

On Fri, May 20, 2011 at 9:21 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 2011/5/20 Richard Guenther <richard.guenther@gmail.com>:
>> On Thu, May 19, 2011 at 7:52 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> To illustrate in which scenario code in tree-ssa-forwprop doesn't help
>>> is binop-tor4.c
>>>
>>> w/o this patch we get
>>>
>>>
>>> foo (int a, int b, int c)
>>> {
>>>  int e;
>>>  int d;
>>>  int D.2701;
>>>  _Bool D.2700;
>>>  _Bool D.2699;
>>>  _Bool D.2698;
>>>  _Bool D.2697;
>>>  _Bool D.2696;
>>>  int D.2695;
>>>
>>> <bb 2>:
>>>  D.2695_3 = b_2(D) | a_1(D);
>>>  d_4 = D.2695_3 != 0;
>>>  D.2696_5 = a_1(D) == 0;
>>>  D.2697_6 = b_2(D) == 0;
>>>  D.2698_7 = D.2697_6 | D.2696_5;
>>>  D.2699_9 = c_8(D) != 0;
>>>  D.2700_10 = D.2698_7 | D.2699_9;
>>>  e_11 = (int) D.2700_10;
>>>  D.2701_12 = e_11 | d_4;
>>>  return D.2701_12;
>>> }
>>>
>>> Of interest is here  D.2701_12, which doesn't have a type sinking.
>>> This is caused by
>>>
>>>  D.2695_3 = b_2(D) | a_1(D);
>>>  d_4 = D.2695_3 != 0;
>>>
>>> which is a comparison result with implicit integer cast. So maybe the
>>> solution here could be to first doing boolification of comparison in
>>> gimplifier. By this, the code for type-sinking in my patch could go
>>> away.
>>
>> Well, forwprop either needs to be teached to handle this different kind
>> of widening
>>
>>  d_4 = D.2687_3 != 0;
>>  e_11 = (int) D.2692_10;
>>  D.2694_12 = e_11 | d_4;
>>
>> or indeed comparisons should also be boolified (which I think they
>> should - they are also predicate producers).
>>
>> Still whether sinking or hoisting the stuff is the right thing, reassoc
>> is not the place to do it.
>>
>> Richard.
>
> So I tested code to do boolifying of comparison in gimplifier.  This
> works so far nice when fold_convert doesn't hoist for boolean-types.
> But in pass  forwprop (see here function forward_propagate_comparison)
> does again type hoisting, which destroys of coures the boolified
> comparisons and so later reassociation pass has again the issue about
> finding matches.
> To introduce (as you suggested) into tree-ssa-forwprop the type
> sinking, therefore doesn't work.  As type hoisting is for sure the
> better final result of an expression, but on expression folding
> passes it has advantages to use type sinking instead.
> So this might be a thing for a different pass, or in reassoc-pass
> itself (as patch does) as here type-sinking helps to combine.  As
> after reassociation again the forward-propagation happens, we have
> still the better final expression variant as result.
>
> So how to continue here?

Please send me the boolification of comparisons patch you have,
as that is the right way to continue.  forwprop shouldn't undo
this (if it does, it does so via fold).

Richard.

> Regards,
> Kai
>

  reply	other threads:[~2011-05-21  9:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-19 13:11 Kai Tietz
2011-05-19 13:17 ` Jakub Jelinek
2011-05-19 13:20   ` Kai Tietz
2011-05-19 13:30 ` Richard Guenther
2011-05-19 13:32   ` Kai Tietz
2011-05-19 13:38     ` Richard Guenther
2011-05-19 13:40       ` Kai Tietz
2011-05-19 13:51         ` Richard Guenther
2011-05-19 15:28           ` Kai Tietz
2011-05-19 15:41             ` Richard Guenther
2011-05-19 15:51               ` Kai Tietz
2011-05-19 16:16                 ` Richard Guenther
2011-05-19 17:23                   ` Kai Tietz
2011-05-19 19:20                     ` Kai Tietz
2011-05-20 10:37                       ` Richard Guenther
2011-05-21  0:12                         ` Kai Tietz
2011-05-21 16:17                           ` Richard Guenther [this message]
2011-05-19 13:37   ` Richard Guenther
2011-05-20  3:45 ` Eric Botcazou
2011-05-20  4:10   ` Kai Tietz

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='BANLkTikrF3rF6uM5FVsDeas=TdjvWGJgGA@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --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).