public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Development <gcc@gcc.gnu.org>,
	Richard Sandiford <richard.sandiford@arm.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Bill Schmidt <wschmidt@linux.ibm.com>
Subject: Re: How to extend SLP to support this case
Date: Wed, 11 Mar 2020 13:34:08 +0800	[thread overview]
Message-ID: <1f8a628d-5fd1-98d2-d08b-c2018aee6abd@linux.ibm.com> (raw)
In-Reply-To: <CAFiYyc0P0yFB=okun_XA-hUtkw2Xf_9481wcUL5gQV8Jdghtaw@mail.gmail.com>

Hi Richi,

on 2020/3/10 下午7:14, Richard Biener wrote:
> On Tue, Mar 10, 2020 at 12:12 PM Richard Biener
> <richard.guenther@gmail.com> wrote:
>>
>> On Tue, Mar 10, 2020 at 7:52 AM Kewen.Lin <linkw@linux.ibm.com> wrote:
>>>
>>> Hi all,
>>>
>>> I'm investigating whether GCC can vectorize the below case on ppc64le.
>>>
>>>   extern void test(unsigned int t[4][4]);
>>>
>>>   void foo(unsigned char *p1, int i1, unsigned char *p2, int i2)
>>>   {
>>>     unsigned int tmp[4][4];
>>>     unsigned int a0, a1, a2, a3;
>>>
>>>     for (int i = 0; i < 4; i++, p1 += i1, p2 += i2) {
>>>       a0 = (p1[0] - p2[0]) + ((p1[4] - p2[4]) << 16);
>>>       a1 = (p1[1] - p2[1]) + ((p1[5] - p2[5]) << 16);
>>>       a2 = (p1[2] - p2[2]) + ((p1[6] - p2[6]) << 16);
>>>       a3 = (p1[3] - p2[3]) + ((p1[7] - p2[7]) << 16);
>>>
>>>       int t0 = a0 + a1;
>>>       int t1 = a0 - a1;
>>>       int t2 = a2 + a3;
>>>       int t3 = a2 - a3;
>>>
>>>       tmp[i][0] = t0 + t2;
>>>       tmp[i][2] = t0 - t2;
>>>       tmp[i][1] = t1 + t3;
>>>       tmp[i][3] = t1 - t3;
>>>     }
>>>     test(tmp);
>>>   }
>>>
...
>>> From the above, the key thing is to group tmp[i][j] i=/0,1,2,3/ together, eg:
>>>   tmp[i][0] i=/0,1,2,3/ (one group)
>>>   tmp[i][1] i=/0,1,2,3/ (one group)
>>>   tmp[i][2] i=/0,1,2,3/ (one group)
>>>   tmp[i][3] i=/0,1,2,3/ (one group)
>>>
>>> which tmp[i][j] group have the same isomorphic computations.  But currently
>>> SLP is unable to divide group like this way. (call it as A-way for now)
>>>
>>> It's understandable since it has better adjacent store groups like,
>>>   tmp[0][i] i=/0,1,2,3/ (one group)
>>>   tmp[1][i] i=/0,1,2,3/ (one group)
>>>   tmp[2][i] i=/0,1,2,3/ (one group)
>>>   tmp[3][i] i=/0,1,2,3/ (one group)
> 
> Note this is how the non-SLP path will (try to) vectorize the loop.
> 

Oops, sorry for the confusion with poor writing, it's intended to show
how the current SLP group those 16 stores tmp[i][j] i,j=/0,1,2,3/
with completely unrolled.  I saw it split 16 stmts into 4 groups like
this way finally.

BR,
Kewen


  reply	other threads:[~2020-03-11  5:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  6:52 Kewen.Lin
2020-03-10 11:12 ` Richard Biener
2020-03-10 11:14   ` Richard Biener
2020-03-11  5:34     ` Kewen.Lin [this message]
2020-03-10 11:31   ` Tamar Christina
2020-03-11  3:58     ` Kewen.Lin
2020-03-13 11:57     ` Richard Biener
2020-03-18 11:37       ` Tamar Christina
2020-03-11  1:56   ` Kewen.Lin

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=1f8a628d-5fd1-98d2-d08b-c2018aee6abd@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=gcc@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=richard.sandiford@arm.com \
    --cc=segher@kernel.crashing.org \
    --cc=wschmidt@linux.ibm.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).