public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Bin.Cheng" <amker.cheng@gmail.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Cc: Richard Biener <richard.guenther@gmail.com>
Subject: Re: [PATCH GCC][1/2]Feed bound computation to folder in loop split
Date: Fri, 16 Jun 2017 16:58:00 -0000	[thread overview]
Message-ID: <CAHFci2-fLz84=9Jo4wv0ggiScu6PkC1OQxf4vZMVQJ6JY+_qBA@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1706161838460.2493@stedding.saclay.inria.fr>

On Fri, Jun 16, 2017 at 5:48 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Fri, 16 Jun 2017, Bin.Cheng wrote:
>
>> On Fri, Jun 16, 2017 at 5:16 PM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>>>
>>> On June 16, 2017 3:31:32 PM GMT+02:00, "Bin.Cheng"
>>> <amker.cheng@gmail.com> wrote:
>>>>
>>>> On Fri, Jun 16, 2017 at 2:10 PM, Richard Biener
>>>> <richard.guenther@gmail.com> wrote:
>>>>>
>>>>> On Fri, Jun 16, 2017 at 3:06 PM, Bin.Cheng <amker.cheng@gmail.com>
>>>>
>>>> wrote:
>>>>>>
>>>>>> On Fri, Jun 16, 2017 at 11:49 AM, Richard Biener
>>>>>> <richard.guenther@gmail.com> wrote:
>>>>>>>
>>>>>>> On Wed, Jun 14, 2017 at 3:07 PM, Bin Cheng <Bin.Cheng@arm.com>
>>>>
>>>> wrote:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>> Loop split forces intermediate computation to gimple operands all
>>>>
>>>> the time when
>>>>>>>>
>>>>>>>> computing bound information.  This is not good since folding
>>>>
>>>> opportunities are
>>>>>>>>
>>>>>>>> missed.  This patch fixes the issue by feeding all computation to
>>>>
>>>> folder and only
>>>>>>>>
>>>>>>>> forcing to gimple operand at last.
>>>>>>>>
>>>>>>>> Bootstrap and test on x86_64 and AArch64.  Is it OK?
>>>>>>>
>>>>>>>
>>>>>>> Hm?  It uses gimple_build () which should do the same as
>>>>
>>>> fold_buildN in terms
>>>>>>>
>>>>>>> of simplification.
>>>>>>>
>>>>>>> So where does that not work?  It is supposed to be the prefered way
>>>>
>>>> and no
>>>>>>>
>>>>>>> new code should use force_gimple_operand (unless dealing with
>>>>
>>>> generic
>>>>>>>
>>>>>>> coming from other middle-end infrastructure like SCEV or niter
>>>>
>>>> analysis)
>>>>>>
>>>>>> Hmm, current code calls force_gimpele operand several times which
>>>>>> causes the inefficiency.  The patch avoids that and does one call at
>>>>>> the end.
>>>>>
>>>>>
>>>>> But it forces to the same sequence that is used for extending the
>>>>
>>>> expression
>>>>>
>>>>> so folding should work.  Where do you see that it does not?  Note the
>>>>> code uses gimple_build (), not gimple_build_assign ().
>>>>
>>>> In spec2k6/hmmer, when building fast_algorithms.c with below command
>>>> line:
>>>> ./gcc -Ofast -S fast_algorithms.c -o fast_algorithms.S -fdump-tree-all
>>>> -fdump-tree-lsplit
>>>> The lsplit dump contains:
>>>>  <bb 11> [12.75%]:
>>>>  _124 = _197 + 1;
>>>>  _123 = _124 + -1;
>>>>  _115 = MIN_EXPR <_197, _124>;
>>>> Which is generated here.
>>>
>>>
>>> That means we miss a pattern in match.PD to handle this case.
>>
>> I see.  I will withdraw this patch and look in that direction.
>
>
> 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 Marc,
Thanks for pointing out the exact patterns.  The variables are of int
type.  The redundant operation disappears in reduced test case though.

Thanks,
bin
>
> --
> Marc Glisse

  reply	other threads:[~2017-06-16 16:58 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 [this message]
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
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='CAHFci2-fLz84=9Jo4wv0ggiScu6PkC1OQxf4vZMVQJ6JY+_qBA@mail.gmail.com' \
    --to=amker.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).