diff mbox series

tree-optimization/115652 - more fixing of the fix

Message ID 20240628114814.B3691382DB1E@sourceware.org
State New
Headers show
Series tree-optimization/115652 - more fixing of the fix | expand

Commit Message

Richard Biener June 28, 2024, 11:47 a.m. UTC
The following addresses the corner case of an outer loop with an empty
header where we end up asking for the BB of a NULL stmt by
special-casing this case.

Bootstrap and regtest running on x86_64-unknown-linux-gnu, the patch
fixes observed ICEs on GCN.

	PR tree-optimization/115652
	* tree-vect-slp.cc (vect_schedule_slp_node): Handle the case
	where the outer loop header block is empty.
---
 gcc/tree-vect-slp.cc | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 174b4800fa9..dd9017e5b3a 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -9750,8 +9750,15 @@  vect_schedule_slp_node (vec_info *vinfo,
 	      {
 		gimple_stmt_iterator si2
 		  = gsi_after_labels (LOOP_VINFO_LOOP (loop_vinfo)->header);
-		if (last_stmt != *si2
-		    && vect_stmt_dominates_stmt_p (last_stmt, *si2))
+		if ((gsi_end_p (si2)
+		     && (LOOP_VINFO_LOOP (loop_vinfo)->header
+			 != gimple_bb (last_stmt))
+		     && dominated_by_p (CDI_DOMINATORS,
+					LOOP_VINFO_LOOP (loop_vinfo)->header,
+					gimple_bb (last_stmt)))
+		    || (!gsi_end_p (si2)
+			&& last_stmt != *si2
+			&& vect_stmt_dominates_stmt_p (last_stmt, *si2)))
 		  si = si2;
 	      }
 	}