https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121202
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- (gdb) p debug_gimple_stmt (last_stmt) vect__9.23_46 = { 1, 1, 1, 1 } << a.2_1; $4 = void (gdb) p debug_gimple_stmt (stmt) # VUSE <.MEM_14> a.2_1 = a; $5 = void (gdb) p debug_bb_n (3) <bb 3> [local count: 105119322]: a.2_1 = a; vect__9.23_46 = { 1, 1, 1, 1 } << a.2_1; if (a.2_1 <= 1) so there's proper dominance. But (gdb) p gimple_uid (last_stmt) $8 = 0 (gdb) p gimple_uid (stmt) $7 = 4294967295 and we hit if (gimple_uid (gsi_stmt (gsi1)) == -1u) return false; this is because the stmts are externals and those do not get initialized UIDs (aka stmt_vec_info). This usually works but what breaks it is the -1 UID on the condition stmt. We should have inserted the vect__9.23_46 = { 1, 1, 1, 1 } << a.2_1; in the preheader, so that's arguably what triggers the issue here - and, of course, that we have an invariant stmt inside of the loop.