------- Comment #5 from rguenth at gcc dot gnu dot org 2010-01-30 16:52 ------- (In reply to comment #3) > Hack that may be worth trying: > Index: tree-ssa-dce.c > =================================================================== > --- tree-ssa-dce.c (revision 156352) > +++ tree-ssa-dce.c (working copy) > @@ -683,7 +683,10 @@ propagate_necessity (struct edge_list *e > { > for (k = 0; k < gimple_phi_num_args (stmt); k++) > { > + tree t = gimple_phi_arg_def (stmt, k); > basic_block arg_bb = gimple_phi_arg_edge (stmt, k)->src; > + if (is_gimple_min_invariant (t)) > + continue; > if (arg_bb != ENTRY_BLOCK_PTR > && ! TEST_BIT (visited_control_parents, arg_bb->index)) > { >
But that would break for example if (i) j = 1; else j = 0; where the PHI only has constants. I think the problem is that the control dependence for the constant is the wrong one (if we didn't have a constant argument in the PHI but an assignment as in the original source the same thing would happen - we'd mark an unrelated control stmt necessary). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42906