https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117140
--- Comment #7 from Tamar Christina <tnfchris at gcc dot gnu.org> --- For this statement somehow the location of the gsi ends up having first == last, so gsi_insert_before just silently ignores the insert. The ICE happens because for this one BB, no vector statement is ever emitted to the BB. Reverting to the original code I had diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 8727246c27a..c028594e18b 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -11128,7 +11128,8 @@ vectorize_slp_instance_root_stmt (vec_info *vinfo, slp_tree node, slp_instance i can't support lane > 1 at this time. */ gcc_assert (instance->root_stmts.length () == 1); auto root_stmt_info = instance->root_stmts[0]; - auto last_stmt = STMT_VINFO_STMT (root_stmt_info); + auto last_stmt = vect_find_first_scalar_stmt_in_slp (node)->stmt; gimple_stmt_iterator rgsi = gsi_for_stmt (last_stmt); gimple *vec_stmt = NULL; gcc_assert (!SLP_TREE_VEC_DEFS (node).is_empty ()); works correctly, but I'd like to figure out why. So looking into that first.