tree-optimization/95576 - fix compare-debug issue with SLP vectorization
authorRichard Biener <rguenther@suse.de>
Wed, 10 Jun 2020 13:16:23 +0000 (15:16 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 10 Jun 2020 16:06:41 +0000 (18:06 +0200)
The following avoids leading debug stmts in BB vectorizer regions.

2020-06-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/95576
* tree-vect-slp.c (vect_slp_bb): Skip leading debug stmts.

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

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

diff --git a/gcc/testsuite/g++.dg/vect/pr95576.cc b/gcc/testsuite/g++.dg/vect/pr95576.cc
new file mode 100644 (file)
index 0000000..64e0e2d
--- /dev/null
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-additional-options "-O3 -fno-tree-forwprop -fcompare-debug" }
+
+struct S {
+  virtual ~S();
+  struct S *s;
+  virtual void m();
+  int f;
+  void *d;
+};
+
+struct T : S {
+  void m();
+};
+
+S::~S() {
+  if (s) {
+    s->f = 0;
+    s->d = __null;
+  }
+}
+
+void T::m() {}
index 0217a524f058535653b00b05ab7093ea792bb935..866ce8d37172791d37b5057afa1215df6a1a5336 100644 (file)
@@ -3316,7 +3316,12 @@ vect_slp_bb (basic_block bb)
        {
          gimple *stmt = gsi_stmt (gsi);
          if (is_gimple_debug (stmt))
-           continue;
+           {
+             /* Skip leading debug stmts.  */
+             if (gsi_stmt (region_begin) == stmt)
+               gsi_next (&region_begin);
+             continue;
+           }
          insns++;
 
          if (gimple_location (stmt) != UNKNOWN_LOCATION)
@@ -3325,6 +3330,8 @@ vect_slp_bb (basic_block bb)
          if (!vect_find_stmt_data_reference (NULL, stmt, &datarefs))
            break;
        }
+      if (gsi_end_p (region_begin))
+       break;
 
       /* Skip leading unhandled stmts.  */
       if (gsi_stmt (region_begin) == gsi_stmt (gsi))