public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Kugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC][PR82479] missing popcount builtin detection
Date: Wed, 31 Jan 2018 11:05:00 -0000	[thread overview]
Message-ID: <CAFiYyc15+U_WgDmNys=ep=+uKm9usLCz-2YHYYBGJGZBN8djKg@mail.gmail.com> (raw)
In-Reply-To: <CAELXzTOXPkz+Uy15PO=X8S8qvE2znQNXz8knqKHHUEU9wHRP2w@mail.gmail.com>

On Wed, Jan 31, 2018 at 11:28 AM, Kugan Vivekanandarajah
<kugan.vivekanandarajah@linaro.org> wrote:
> Hi Richard,
>
> Thanks for the review.
> On 25 January 2018 at 20:04, Richard Biener <richard.guenther@gmail.com> wrote:
>> On Wed, Jan 24, 2018 at 10:56 PM, Kugan Vivekanandarajah
>> <kugan.vivekanandarajah@linaro.org> wrote:
>>> Hi All,
>>>
>>> Here is a patch for popcount builtin detection similar to LLVM. I
>>> would like to queue this for review for next stage 1.
>>>
>>> 1. This is done part of loop-distribution and effective for -O3 and above.
>>> 2. This does not distribute loop to detect popcount (like
>>> memcpy/memmove). I dont think that happens in practice. Please correct
>>> me if I am wrong.
>>
>> But then it has no business inside loop distribution but instead is
>> doing final value
>> replacement, right?  You are pattern-matching the whole loop after all.  I think
>> final value replacement would already do the correct thing if you
>> teached number of
>> iteration analysis that niter for
>>
>>   <bb 3> [local count: 955630224]:
>>   # b_11 = PHI <b_5(5), b_8(6)>
>>   _1 = b_11 + -1;
>>   b_8 = _1 & b_11;
>>   if (b_8 != 0)
>>     goto <bb 6>; [89.00%]
>>   else
>>     goto <bb 8>; [11.00%]
>>
>>   <bb 6> [local count: 850510900]:
>>   goto <bb 3>; [100.00%]
>
> I am looking into this approach. What should be the scalar evolution
> for b_8 (i.e. b & (b -1) in a loop) should be? This is not clear to me
> and can this be represented with the scev?

No, it's not affine and thus cannot be represented.  You only need the
scalar evolution of the counting IV which is already handled and
the number of iteration analysis needs to handle the above IV - this
is the missing part.

Richard.

> Thanks,
> Kugan
>>
>> is related to popcount (b_5).
>>
>> Richard.
>>
>>> Bootstrapped and regression tested on aarch64-linux-gnu with no new regressions.
>>>
>>> Thanks,
>>> Kugan
>>>
>>> gcc/ChangeLog:
>>>
>>> 2018-01-25  Kugan Vivekanandarajah  <kuganv@linaro.org>
>>>
>>>     PR middle-end/82479
>>>     * tree-loop-distribution.c (handle_popcount): New.
>>>     (pass_loop_distribution::execute): Use handle_popcount.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> 2018-01-25  Kugan Vivekanandarajah  <kuganv@linaro.org>
>>>
>>>     PR middle-end/82479
>>>     * gcc.dg/tree-ssa/popcount.c: New test.

  reply	other threads:[~2018-01-31 10:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 22:17 Kugan Vivekanandarajah
2018-01-25 10:24 ` Richard Biener
2018-01-31 10:41   ` Kugan Vivekanandarajah
2018-01-31 11:05     ` Richard Biener [this message]
2018-02-01  4:08       ` Kugan Vivekanandarajah
2018-02-01 12:21         ` Richard Biener
2018-02-08  0:41           ` Kugan Vivekanandarajah
2018-03-05 15:25             ` Richard Biener
2018-03-06 16:20               ` Bin.Cheng
2018-03-07  8:26                 ` Richard Biener
2018-03-07 11:25                   ` Bin.Cheng
2018-03-08 22:07                     ` Kugan Vivekanandarajah
2018-05-17  2:16               ` Kugan Vivekanandarajah
2018-05-17 10:05                 ` Bin.Cheng
2018-05-31  6:52                   ` Kugan Vivekanandarajah
2018-05-31 17:53                     ` Bin.Cheng
2018-06-01  9:57                       ` Kugan Vivekanandarajah
2018-06-01 10:06                         ` Bin.Cheng
2018-06-01 13:12                           ` Richard Biener
2018-06-05  9:02                             ` Kugan Vivekanandarajah
2018-06-05 11:25                               ` Richard Biener
2018-06-07  0:52                                 ` Kugan Vivekanandarajah
2018-06-07  9:21                                   ` Richard Biener
2018-06-12  3:10                                     ` Kugan Vivekanandarajah
2018-06-14 13:57                                       ` 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='CAFiYyc15+U_WgDmNys=ep=+uKm9usLCz-2YHYYBGJGZBN8djKg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kugan.vivekanandarajah@linaro.org \
    /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).