https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91063
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2019-07-03 Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Reduced testcase -O2 -fopenmp-simd -mavx512f: struct S { void *s; }; int foo (struct S *x) { int r = 0; int i; #pragma omp simd reduction (+ : r) for (i = 0; i < 64; ++i) r += (int) (x->s != 0); return r; } I believe this has been introduced with r272623, but haven't verified that yet. Untested fix below. vect_init_vector_1 inserts the stmt read from stmts sequence into other spots, so it is unhealthy if we iterate using iterator that contains it, it can very well create stmt referencing itself in ->next. --- gcc/tree-vect-stmts.c.jj 2019-07-03 10:24:33.463768431 +0200 +++ gcc/tree-vect-stmts.c 2019-07-03 12:35:48.998435660 +0200 @@ -1496,15 +1496,19 @@ vect_init_vector (stmt_vec_info stmt_inf promotion of invariant/external defs. */ val = gimple_convert (&stmts, TREE_TYPE (type), val); for (gimple_stmt_iterator gsi2 = gsi_start (stmts); - !gsi_end_p (gsi2); gsi_next (&gsi2)) - vect_init_vector_1 (stmt_info, gsi_stmt (gsi2), gsi); + !gsi_end_p (gsi2); ) + { + init_stmt = gsi_stmt (gsi2); + gsi_remove (&gsi2, false); + vect_init_vector_1 (stmt_info, init_stmt, gsi); + } } } val = build_vector_from_val (type, val); } new_temp = vect_get_new_ssa_name (type, vect_simple_var, "cst_"); - init_stmt = gimple_build_assign (new_temp, val); + init_stmt = gimple_build_assign (new_temp, val); vect_init_vector_1 (stmt_info, init_stmt, gsi); return new_temp; }