public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Bin.Cheng" <amker.cheng@gmail.com>
To: Marc Glisse <marc.glisse@inria.fr>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>,
	Richard Biener <richard.guenther@gmail.com>,
		Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH GCC][1/2]Feed bound computation to folder in loop split
Date: Mon, 24 Jul 2017 13:49:00 -0000	[thread overview]
Message-ID: <CAHFci28j=ctLBb-Cp4_ZGdaTqSfAG+CvcCpEjbBJbUemjmG9UQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1707241405290.2780@stedding.saclay.inria.fr>

On Mon, Jul 24, 2017 at 1:16 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Mon, 24 Jul 2017, Bin.Cheng wrote:
>
>>> For _123, we have
>>>
>>>   /* (A +- CST1) +- CST2 -> A + CST3
>>> or
>>> /* Associate (p +p off1) +p off2 as (p +p (off1 + off2)).  */
>>>
>>>
>>> For _115, we have
>>>
>>> /* min (a, a + CST) -> a where CST is positive.  */
>>> /* min (a, a + CST) -> a + CST where CST is negative. */
>>> (simplify
>>>  (min:c @0 (plus@2 @0 INTEGER_CST@1))
>>>   (if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))
>>>    (if (tree_int_cst_sgn (@1) > 0)
>>>     @0
>>>     @2)))
>>>
>>> What is the type of all those SSA_NAMEs?
>>
>> Hi,
>> From the debugging process, there are two issues preventing "(A +-
>> CST1) +- CST2 -> A + CST3" from being applied:
>> A) before we reach this pattern, there is pattern:
>>
>> /* A - B -> A + (-B) if B is easily negatable.  */
>> (simplify
>> (minus @0 negate_expr_p@1)
>> (if (!FIXED_POINT_TYPE_P (type))
>> (plus @0 (negate @1))))
>>
>> which is matched and returned in gimple_simplify_MINUS_EXPR.  So does
>> pattern order matter here?
>
>
> That shouldn't be a problem, normally we always try to resimplify the result
> of the simplification, and the transformation should handle x+1+-1 just as
> well as x+1-1. Is that not happening?
Yes, it's doesn't matter.

>
>> B) When folding "_124 - 1" on the basis of existing stmts sequence
>> like "_124 = _197 + 1;".  The corresponding gimple-match.c code is
>> like:
>
> [...]
>>
>> But since definition of _197 isn't in current stmt sequence, call "o31
>> = do_valueize (valueize, o31)" will return NULL.  As a result, it's
>> not matched.
>
>
> Ah, yes, that problem... Jakub was having a very similar issue a few
> weeks ago, don't know if he found a solution. You could call
> gimple_simplify directly with a different valueization function if
> that's safe. Normally the simplification would wait until the next
> forwprop pass.
Thanks for elaboration.
It's too late for next forwprop pass since we are in between loop
optimizations and need the simplified code for niter analysis.
Function compute_new_first_bound calls gimple_build several times,
it's not likely to replace all gimple_build with gimple_simplify?
Also gimple_simplify could return NULL_TREE, in which case I need to
call gimple_build_assign again.  At last, we don't have interface
fold_seq similar to fold_stmt either.
CCing Jakub if he found a solution.  Thanks.

Thanks,
bin
>
> --
> Marc Glisse

  reply	other threads:[~2017-07-24 13:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 13:07 Bin Cheng
2017-06-16 10:49 ` Richard Biener
2017-06-16 13:06   ` Bin.Cheng
2017-06-16 13:10     ` Richard Biener
2017-06-16 13:31       ` Bin.Cheng
2017-06-16 16:16         ` Richard Biener
2017-06-16 16:23           ` Bin.Cheng
2017-06-16 16:48             ` Marc Glisse
2017-06-16 16:58               ` Bin.Cheng
2017-06-16 17:04               ` Andrew Pinski
2017-07-24 11:45               ` Bin.Cheng
2017-07-24 12:16                 ` Marc Glisse
2017-07-24 13:49                   ` Bin.Cheng [this message]
2017-07-24 13:59                 ` Marc Glisse
2017-07-24 14:06                   ` Bin.Cheng
2017-07-24 14:31                     ` Marc Glisse
2017-07-24 14:37                       ` Bin.Cheng
2017-07-24 14:52                         ` Marc Glisse
2017-07-25 14:32                       ` Richard Biener
2017-07-25 17:45                         ` Marc Glisse
2017-07-26  7:48                           ` Richard Biener
2017-07-26  9:08                             ` Richard Sandiford
2017-07-26  9:38                               ` Marc Glisse
2017-07-26  9:45                                 ` Richard Sandiford
2017-07-26  9:57                                   ` Marc Glisse
2017-07-26 11:13                                     ` Richard Biener
2017-07-26 11:46                             ` Richard Biener

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='CAHFci28j=ctLBb-Cp4_ZGdaTqSfAG+CvcCpEjbBJbUemjmG9UQ@mail.gmail.com' \
    --to=amker.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=marc.glisse@inria.fr \
    --cc=richard.guenther@gmail.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).