[gcc r17-3284] tree-optimization/126861 - ICE with SLP schedule at explicit region start

Richard Biener via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:d42b8b15aa9f246293c976f141df1c1936d93dc6

commit r17-3284-gd42b8b15aa9f246293c976f141df1c1936d93dc6
Author: Richard Biener <[email protected]>
Date:   Fri Aug 14 10:26:00 2026 +0200

    tree-optimization/126861 - ICE with SLP schedule at explicit region start
    
    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.
    
            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.

Diff:
---
 gcc/testsuite/g++.dg/vect/slp-pr126861.cc | 11 +++++++++++
 gcc/tree-vect-slp.cc                      |  3 +--
 2 files changed, 12 insertions(+), 2 deletions(-)

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 000000000000..d9e5f4ea0756
--- /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 bda7ae679e55..985aa4281b31 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -12279,8 +12279,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));
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.