]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/114231 - use patterns for BB SLP discovery root stmts
authorRichard Biener <rguenther@suse.de>
Tue, 5 Mar 2024 09:55:56 +0000 (10:55 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 16 May 2024 09:55:47 +0000 (11:55 +0200)
The following makes sure to use recognized patterns when vectorizing
roots during BB SLP discovery.  We need to apply those late since
during root discovery we've not yet done pattern recognition.
All parts of the vectorizer assume patterns get used, for the testcase
we mix this up when doing live lane computation.

PR tree-optimization/114231
* tree-vect-slp.cc (vect_analyze_slp): Lookup patterns when
processing a BB SLP root.

* gcc.dg/vect/pr114231.c: New testcase.

(cherry picked from commit 04fffbaa87997ac893a9aa68b674c938ba3ecddb)

gcc/testsuite/gcc.dg/vect/pr114231.c [new file with mode: 0644]
gcc/tree-vect-slp.cc

diff --git a/gcc/testsuite/gcc.dg/vect/pr114231.c b/gcc/testsuite/gcc.dg/vect/pr114231.c
new file mode 100644 (file)
index 0000000..5e3a810
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+void f(long*);
+int ff[2];
+void f2(long, long, unsigned long);
+void k(unsigned long x, unsigned long y)
+{
+  long t = x >> ff[0];
+  long t1 = ff[1];
+  unsigned long t2 = y >> ff[0];
+  f2(t1, t+t2, t2);
+}
index 7f9fbb9f3d01c2b9068e9dd82d284f2922a61683..f33e85337abd550e43bde845cade5cbc7f99e26a 100644 (file)
@@ -3410,6 +3410,10 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size)
       for (unsigned i = 0; i < bb_vinfo->roots.length (); ++i)
        {
          vect_location = bb_vinfo->roots[i].roots[0]->stmt;
+         /* Apply patterns.  */
+         for (unsigned j = 0; j < bb_vinfo->roots[i].stmts.length (); ++j)
+           bb_vinfo->roots[i].stmts[j]
+             = vect_stmt_to_vectorize (bb_vinfo->roots[i].stmts[j]);
          if (vect_build_slp_instance (bb_vinfo, bb_vinfo->roots[i].kind,
                                       bb_vinfo->roots[i].stmts,
                                       bb_vinfo->roots[i].roots,