From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/106081 - elide redundant permute
Date: Wed, 26 Jul 2023 13:27:33 +0000 (UTC) [thread overview]
Message-ID: <20230726132733.ufCG5aONAEw6S95vg-kZOG8rqqiII6fkitKkw_UTbew@z> (raw)
The following patch makes sure to elide a redundant permute that
can be merged with existing splats represented as load permutations
as we now do for non-grouped SLP loads. This is the last bit
missing to fix this PR where the main fix was already done by
r14-2117-gdd86a5a69cbda4
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/106081
* tree-vect-slp.cc (vect_optimize_slp_pass::start_choosing_layouts):
Assign layout -1 to splats.
* gcc.dg/vect/pr106081.c: New testcase.
---
gcc/testsuite/gcc.dg/vect/pr106081.c | 33 ++++++++++++++++++++++++++++
gcc/tree-vect-slp.cc | 5 ++++-
2 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/pr106081.c
diff --git a/gcc/testsuite/gcc.dg/vect/pr106081.c b/gcc/testsuite/gcc.dg/vect/pr106081.c
new file mode 100644
index 00000000000..8f97af2d642
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr106081.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math -fdump-tree-optimized" } */
+/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */
+/* { dg-require-effective-target vect_double } */
+/* { dg-require-effective-target vect_unpack } */
+/* { dg-require-effective-target vect_intdouble_cvt } */
+/* { dg-require-effective-target vect_perm } */
+
+struct pixels
+{
+ short a,b,c,d;
+} *pixels;
+struct dpixels
+{
+ double a,b,c,d;
+};
+
+double
+test(double *k)
+{
+ struct dpixels results={};
+ for (int u=0; u<1000*16;u++,k--)
+ {
+ results.a += *k*pixels[u].a;
+ results.b += *k*pixels[u].b;
+ results.c += *k*pixels[u].c;
+ results.d += *k*pixels[u].d;
+ }
+ return results.a+results.b*2+results.c*3+results.d*4;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
+/* { dg-final { scan-tree-dump-times "VEC_PERM" 4 "optimized" { target x86_64-*-* i?86-*-* } } } */
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index e4430248ab5..a1b153035e1 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -4605,7 +4605,10 @@ vect_optimize_slp_pass::start_choosing_layouts ()
IFN_MASK_LOADs). */
gcc_assert (partition.layout == 0 && !m_slpg->vertices[node_i].succ);
if (!STMT_VINFO_GROUPED_ACCESS (dr_stmt))
- continue;
+ {
+ partition.layout = -1;
+ continue;
+ }
dr_stmt = DR_GROUP_FIRST_ELEMENT (dr_stmt);
imin = DR_GROUP_SIZE (dr_stmt) + 1;
tmp_perm.safe_splice (SLP_TREE_LOAD_PERMUTATION (node));
--
2.35.3
next reply other threads:[~2023-07-26 13:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 13:27 Richard Biener [this message]
[not found] <20230726132804.E4E863854826@sourceware.org>
2023-07-26 16:18 ` Jeff Law
2023-07-27 7:52 ` 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=20230726132733.ufCG5aONAEw6S95vg-kZOG8rqqiII6fkitKkw_UTbew@z \
--to=rguenther@suse.de \
--cc=gcc-patches@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).