[PATCH] tree-optimization/126861 - ICE with SLP schedule at explicit region start

Richard Biener <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
We cannot use a random stmt at region start as marker as that might
eventually be a control stmt.  Instead use NULL to mark region
start as documented.

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

	PR tree-optimization/126861
	* tree-vect-slp.cc (vect_schedule_slp_node): Use NULL for
	scheduling at region start.

	* g++.dg/vect/slp-pr126861.cc: New testcase.
---
 gcc/testsuite/g++.dg/vect/slp-pr126861.cc | 11 +++++++++++
 gcc/tree-vect-slp.cc                      |  3 +--
 2 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/vect/slp-pr126861.cc

diff --git a/gcc/testsuite/g++.dg/vect/slp-pr126861.cc b/gcc/testsuite/g++.dg/vect/slp-pr126861.cc
new file mode 100644
index 00000000000..d9e5f4ea075
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/slp-pr126861.cc
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+struct Guard { ~Guard(); };
+void init();
+
+int f (unsigned n1, unsigned n2)
+{
+  Guard g;
+  init();
+  return (n1 != 0) + (n2 != 0);
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index aa3f1318f87..89a67e4eb38 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -12277,8 +12277,7 @@ vect_schedule_slp_node (vec_info *vinfo,
       else if (!last_stmt)
 	{
 	  si = gsi_after_labels (vinfo->bbs[0]);
-	  /* ???  last_stmt can be NULL if the block is empty.  */
-	  last_stmt = gsi_stmt (si);
+	  /* last_stmt NULL marks the region start.  */
 	}
       else if (is_a <gphi *> (last_stmt))
 	si = gsi_after_labels (gimple_bb (last_stmt));
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.