[backport from gcc-4.8/trunk r186164, follow-up fix to the patch that fixed PR54902 ] gcc/ 2012-04-05 Richard Guenther * tree-ssa-dse.c (dse_optimize_stmt): Remember the stmt basic-block before removing it. --- gcc-4.7.2/gcc/tree-ssa-dse.c.~1~ 2012-10-13 16:24:15.000000000 +0200 +++ gcc-4.7.2/gcc/tree-ssa-dse.c 2012-10-13 16:25:52.000000000 +0200 @@ -232,6 +232,8 @@ dse_optimize_stmt (gimple_stmt_iterator gimple_get_lhs (use_stmt), 0))) || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt))) { + basic_block bb; + /* If use_stmt is or might be a nop assignment, e.g. for struct { ... } S a, b, *p; ... b = a; b = b; @@ -258,8 +260,9 @@ dse_optimize_stmt (gimple_stmt_iterator unlink_stmt_vdef (stmt); /* Remove the dead store. */ + bb = gimple_bb (stmt); if (gsi_remove (&gsi, true)) - bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index); + bitmap_set_bit (need_eh_cleanup, bb->index); /* And release any SSA_NAMEs set in this statement back to the SSA_NAME manager. */