https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96722
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
I don't have a good idea either but eventually something along the following -
if we remove any control stmt in a clobbers control dependence chain
force-remove the clobber. Obviously as written it's highly inefficient,
such tracking would need to be done only once per BB. It might also be
too conservative - eventually only the "immediate" control dependence matters
(but the control dependence machinery does not give us this easily).
Eventually we can also check the last_stmt_necessary bitmap instead
of looking at last_stmt itself.
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index fae5ae72340..9066dbf6373 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1428,6 +1431,23 @@ eliminate_unnecessary_stmts (void)
break;
}
}
+ if (!dead && cd)
+ {
+ bitmap_iterator bi;
+ unsigned edge_number;
+ EXECUTE_IF_SET_IN_BITMAP (cd->get_edges_dependent_on
+ (bb->index),
+ 0, edge_number, bi)
+ {
+ basic_block cd_bb = cd->get_edge_src (edge_number);
+ if (cd_bb != bb
+ && !gimple_plf (last_stmt (cd_bb),
STMT_NECESSARY))
+ {
+ dead = true;
+ break;
+ }
+ }
+ }
if (!dead)
{
bitmap_clear (debug_seen);
@@ -1665,6 +1685,7 @@ tree_dce_done (bool aggressive)
if (aggressive)
{
delete cd;
+ cd = NULL;
sbitmap_free (visited_control_parents);
sbitmap_free (last_stmt_necessary);
sbitmap_free (bb_contains_live_stmts);