fix hybrid SLP discovery debug stmt issue
authorRichard Biener <rguenther@suse.de>
Mon, 23 Nov 2020 12:46:35 +0000 (13:46 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 23 Nov 2020 14:07:43 +0000 (15:07 +0100)
This properly skips debug USE_STMTs when looking for non-SLP sinks.

2020-11-23  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (maybe_push_to_hybrid_worklist): Skip
debug stmts.

* g++.dg/vect/simd-12.cc: New testcase.

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

diff --git a/gcc/testsuite/g++.dg/vect/simd-12.cc b/gcc/testsuite/g++.dg/vect/simd-12.cc
new file mode 100644 (file)
index 0000000..a3f18d3
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math -g" } */
+
+template <typename> class complex;
+template <typename _Tp> complex<_Tp> operator+(complex<_Tp>, complex<_Tp> __y) {
+  complex<_Tp> __r;
+  __r += __y;
+  return __r;
+}
+template <typename _Tp> complex<_Tp> operator*(complex<_Tp>, complex<_Tp> __y) {
+  complex<_Tp> __r;
+  __r *= __y;
+  return __r;
+}
+template <> class complex<double> {
+public:
+  void operator+=(complex __z) { _M_value += __z.__rep(); }
+  void operator*=(complex __z) {
+    _Complex __t = __z.__rep();
+    _M_value *= __t;
+  }
+  _Complex __rep() { return _M_value; }
+  _Complex _M_value;
+};
+template <typename> class Vector {
+  void equ();
+  complex<double> *val;
+};
+template <typename Number> void Vector<Number>::equ() {
+  Number c;
+  for (int i; i; ++i) {
+    complex<double> __trans_tmp_2 = c * val[i];
+    val[i] = val[i] + __trans_tmp_2;
+  }
+}
+template class Vector<complex<double> >;
index 59a8630f74aaa43e6a4df03fa6745dbc04fa452e..da3ef433161b97bd903f5c96e21174873e1e6564 100644 (file)
@@ -3191,6 +3191,8 @@ maybe_push_to_hybrid_worklist (vec_info *vinfo,
       any_def = true;
       FOR_EACH_IMM_USE_FAST (use_p, iter2, DEF_FROM_PTR (def_p))
        {
+         if (is_gimple_debug (USE_STMT (use_p)))
+           continue;
          stmt_vec_info use_info = vinfo->lookup_stmt (USE_STMT (use_p));
          /* An out-of loop use means this is a loop_vect sink.  */
          if (!use_info)