]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/116658 - latent issue in vect_is_slp_load_node
authorRichard Biener <rguenther@suse.de>
Tue, 10 Sep 2024 07:39:16 +0000 (09:39 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 10 Sep 2024 09:47:30 +0000 (11:47 +0200)
Permute nodes do not have a representative so we have to guard
vect_is_slp_load_node against those.

PR tree-optimization/116658
* tree-vect-slp.cc (vect_is_slp_load_node): Make sure
node isn't a permute.

* g++.dg/vect/pr116658.cc: New testcase.

gcc/testsuite/g++.dg/vect/pr116658.cc [new file with mode: 0644]
gcc/tree-vect-slp.cc

diff --git a/gcc/testsuite/g++.dg/vect/pr116658.cc b/gcc/testsuite/g++.dg/vect/pr116658.cc
new file mode 100644 (file)
index 0000000..c3ff23a
--- /dev/null
@@ -0,0 +1,58 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-O3" }
+// { dg-additional-options "-mavx512f" { target avx512f } }
+
+struct bb {
+  bb operator+=(bb bc) {
+      bd[0] += bc.bd[0];
+    return *this;
+  }
+  bb operator-=(bb bc) {
+      bd[0] -= bc.bd[0];
+    return *this;
+  }
+  bb operator*=(double be) {
+      bd[0] *= be;
+    return *this;
+  }
+  double bd[1];
+};
+
+bb operator+(bb n, bb v) {
+  bb bf = n;
+  return bf += v;
+}
+
+bb operator-(bb n, bb v) {
+  bb bf = n;
+  return bf -= v;
+}
+bb operator*(double n, bb v) {
+  bb bf = v;
+  return bf *= n;
+}
+
+using az = bb;
+struct cc {
+  void apply(bb *ci) {
+  bb xm[1];
+  for (int cm = 0; cm < 2; ++cm) {
+    az cn, co = cv[cm] * xm[0];
+    ci[cm] = cn + co;
+    ci[-1] = cn - co;
+  }
+  }
+  double *cu;
+  double *cv;
+};
+void dc(unsigned de, int di, az *dk, az *dl, cc dh) {
+  for (int c; c < 1024; ++c) {
+    if (de & 1)
+      dh.apply(dk);
+    if (de & 2)
+      dh.apply(dl);
+    dk += di;
+    dl += di;
+  }
+}
index 0fb17340bd3c0e79dad06951853fed1cce66bbc6..31c7e20f8c9a643720b14c9a16c5e196d2de34fb 100644 (file)
@@ -3265,9 +3265,10 @@ calculate_unrolling_factor (poly_uint64 nunits, unsigned int group_size)
 static inline bool
 vect_is_slp_load_node  (slp_tree root)
 {
-  return SLP_TREE_DEF_TYPE (root) == vect_internal_def
-        && STMT_VINFO_GROUPED_ACCESS (SLP_TREE_REPRESENTATIVE (root))
-        && DR_IS_READ (STMT_VINFO_DATA_REF (SLP_TREE_REPRESENTATIVE (root)));
+  return (SLP_TREE_CODE (root) != VEC_PERM_EXPR
+         && SLP_TREE_DEF_TYPE (root) == vect_internal_def
+         && STMT_VINFO_GROUPED_ACCESS (SLP_TREE_REPRESENTATIVE (root))
+         && DR_IS_READ (STMT_VINFO_DATA_REF (SLP_TREE_REPRESENTATIVE (root))));
 }