https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80158
--- Comment #10 from Bill Schmidt <wschmidt at gcc dot gnu.org> --- Pretty certain the problem is in this chunk: if (bump == 0) { tree lhs = gimple_assign_lhs (c->cand_stmt); gassign *copy_stmt = gimple_build_assign (lhs, basis_name); gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); gsi_replace (&gsi, copy_stmt, false); c->cand_stmt = copy_stmt; if (dump_file && (dump_flags & TDF_DETAILS)) stmt_to_print = copy_stmt; } We need a gimple_set_bb (copy_stmt, gimple_bb (c->cand_stmt)) in here if we're going to rely on the BB information for dominators subsequently. There may be other cases like this in the code.