public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/98138] BB vect fail to SLP one case
Date: Mon, 07 Dec 2020 03:10:38 +0000 [thread overview]
Message-ID: <bug-98138-4-E5gxk01bE4@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98138-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98138
--- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> So the expected vectorization builds vectors
>
> { tmp[0][0], tmp[1][0], tmp[2][0], tmp[3][0] }
>
> that's not SLP, SLP tries to build the
>
> { tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3] }
>
> vector and "succeeds" - the SLP tree turns out to be
> highly inefficient though. So for the stores your desire
> is to see an interleaving scheme with VF 4 (the number of
> iterations). But interleaving fails because it would require
> a VF of 16 and there are not enough iteration in the loop.
>
> The classical SLP scheme degenerates (also due to the plus/minus
> mixed ops) to uniform vectors as we venture beyond the a{0,2} {+,-} a{1,3}
> expression.
>
> Starting SLP discovery from the grouped loads would get things going
> up to the above same expression.
>
> So not sure what's the best approach to this case. The testcase
> can be simplified still showing the SLP discovery issue:
>
> extern void test(unsigned int t[4][4]);
>
> void foo(int *p1, int i1, int *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]);
> a1 = (p1[1] - p2[1]);
> a2 = (p1[2] - p2[2]);
> a3 = (p1[3] - p2[3]);
>
> 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);
> }
>
> So it's basically SLP discovery degenerating to an interleaving scheme
> on the load side but not actually "implementing" it.
IIUC, in current implementation, we get four grouped stores:
{ tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3] } /i=0,1,2,3/ independently
When all these tryings fail, could we do some re-try on the groups
{ tmp[0][i], tmp[1][i], tmp[2][i], tmp[3][i] } /i=0,1,2,3/
with one extra intermediate layer covering those original groups, then start
from these newly adjusted groups? the built operands should isomorphic then.
May be too hackish?
next prev parent reply other threads:[~2020-12-07 3:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 10:46 [Bug tree-optimization/98138] New: " linkw at gcc dot gnu.org
2020-12-04 10:52 ` [Bug tree-optimization/98138] " linkw at gcc dot gnu.org
2020-12-04 12:19 ` rguenth at gcc dot gnu.org
2020-12-07 3:10 ` linkw at gcc dot gnu.org [this message]
2021-01-05 8:42 ` linkw at gcc dot gnu.org
2021-01-06 3:29 ` linkw at gcc dot gnu.org
2021-01-06 9:48 ` rguenth at gcc dot gnu.org
2021-01-12 7:23 ` linkw at gcc dot gnu.org
2021-01-12 7:25 ` linkw at gcc dot gnu.org
2021-08-04 10:31 ` rguenth at gcc dot gnu.org
2022-07-06 10:39 ` ktkachov at gcc dot gnu.org
2023-02-01 8:19 ` manolis.tsamis at vrull dot eu
2023-10-04 22:37 ` jiangning.liu at amperecomputing dot com
2023-10-05 6:58 ` rguenth at gcc dot gnu.org
2023-10-09 7:38 ` rguenth at gcc dot gnu.org
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=bug-98138-4-E5gxk01bE4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.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).