public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/110443 - prevent SLP splat of gathers
Date: Wed, 28 Jun 2023 09:12:33 +0000 (UTC)	[thread overview]
Message-ID: <20230628091233.4kFm1bAQXDLtxQTkFyJSoULqzTQtMYxA7MRsehnEGtM@z> (raw)

The following prevents non-grouped load SLP in case the element
to splat is from a gather operation.  While it should be possible
to support this it is not similar to the single element interleaving
case I was trying to mimic here.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/110443
	* tree-vect-slp.cc (vect_build_slp_tree_1): Reject non-grouped
	gather loads.

	* gcc.dg/torture/pr110443.c: New testcase.
---
 gcc/testsuite/gcc.dg/torture/pr110443.c | 21 +++++++++++++++++++++
 gcc/tree-vect-slp.cc                    |  3 ++-
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr110443.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr110443.c b/gcc/testsuite/gcc.dg/torture/pr110443.c
new file mode 100644
index 00000000000..61cf705869c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr110443.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+typedef struct {
+  float real;
+  float imag;
+} complex_t;
+extern unsigned char fftorder[];
+float *a52_imdct_256_data;
+int a52_imdct_256_i, a52_imdct_256_k;
+float a52_imdct_256_b_r;
+void a52_imdct_256()
+{
+  complex_t buf1[64];
+  a52_imdct_256_i = 0;
+  for (; a52_imdct_256_i < 64; a52_imdct_256_i++) {
+    a52_imdct_256_k = fftorder[a52_imdct_256_i];
+    buf1[a52_imdct_256_i].real = buf1[a52_imdct_256_i].imag =
+        a52_imdct_256_data[a52_imdct_256_k];
+  }
+  a52_imdct_256_b_r = buf1[0].real * buf1[0].imag;
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 8cb1ac1f319..355d078d66e 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -1291,7 +1291,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		 vectorization.  For loop vectorization we can handle
 		 splats the same we handle single element interleaving.  */
 	      && (is_a <bb_vec_info> (vinfo)
-		  || stmt_info != first_stmt_info))
+		  || stmt_info != first_stmt_info
+		  || STMT_VINFO_GATHER_SCATTER_P (stmt_info)))
 	    {
 	      /* Not grouped load.  */
 	      if (dump_enabled_p ())
-- 
2.35.3

                 reply	other threads:[~2023-06-28  9:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230628091233.4kFm1bAQXDLtxQTkFyJSoULqzTQtMYxA7MRsehnEGtM@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).