summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dce.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-20 12:30:15 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-20 12:30:15 +0000
commit0672b2688cf41e5ddb0b6a92dd60a990afbc567d (patch)
treee5b239c53d0c17612f9f4897508eeeb107dc50dc /gcc/tree-ssa-dce.c
parent34cb646f8f7cffe6488894c39fb35396a8bce0de (diff)
downloadgcc-0672b2688cf41e5ddb0b6a92dd60a990afbc567d.tar.gz
2010-01-20 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42717 * tree-ssa-dce.c (get_live_post_dom): Remove. (forward_edge_to_pdom): Take an arbitrary edge to copy degenerate PHI args from. (remove_dead_stmt): Use the first post-dominator even if it does not contain live statements as redirection destination. * gcc.c-torture/compile/pr42717.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156076 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-dce.c')
-rw-r--r--gcc/tree-ssa-dce.c65
1 files changed, 15 insertions, 50 deletions
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index bb24b6254d2..4e3499aa6e1 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -917,27 +917,6 @@ remove_dead_phis (basic_block bb)
return something_changed;
}
-/* Find first live post dominator of BB. */
-
-static basic_block
-get_live_post_dom (basic_block bb)
-{
- basic_block post_dom_bb;
-
-
- /* The post dominance info has to be up-to-date. */
- gcc_assert (dom_info_state (CDI_POST_DOMINATORS) == DOM_OK);
-
- /* Get the immediate post dominator of bb. */
- post_dom_bb = get_immediate_dominator (CDI_POST_DOMINATORS, bb);
- /* And look for first live one. */
- while (post_dom_bb != EXIT_BLOCK_PTR
- && !TEST_BIT (bb_contains_live_stmts, post_dom_bb->index))
- post_dom_bb = get_immediate_dominator (CDI_POST_DOMINATORS, post_dom_bb);
-
- return post_dom_bb;
-}
-
/* Forward edge E to respective POST_DOM_BB and update PHIs. */
static edge
@@ -961,10 +940,9 @@ forward_edge_to_pdom (edge e, basic_block post_dom_bb)
if (!gimple_seq_empty_p (phi_nodes (post_dom_bb)))
{
/* We are sure that for every live PHI we are seeing control dependent BB.
- This means that we can look up the end of control dependent path leading
- to the PHI itself. */
+ This means that we can pick any edge to duplicate PHI args from. */
FOR_EACH_EDGE (e2, ei, post_dom_bb->preds)
- if (e2 != e && dominated_by_p (CDI_POST_DOMINATORS, e->src, e2->src))
+ if (e2 != e)
break;
for (gsi = gsi_start_phis (post_dom_bb); !gsi_end_p (gsi);)
{
@@ -972,40 +950,27 @@ forward_edge_to_pdom (edge e, basic_block post_dom_bb)
tree op;
source_location locus;
- /* Dead PHI do not imply control dependency. */
- if (!gimple_plf (phi, STMT_NECESSARY)
- && is_gimple_reg (gimple_phi_result (phi)))
- {
- gsi_next (&gsi);
- continue;
- }
- if (gimple_phi_arg_def (phi, e->dest_idx))
- {
- gsi_next (&gsi);
- continue;
- }
-
- /* We didn't find edge to update. This can happen for PHIs on virtuals
- since there is no control dependency relation on them. We are lost
- here and must force renaming of the symbol. */
+ /* PHIs for virtuals have no control dependency relation on them.
+ We are lost here and must force renaming of the symbol. */
if (!is_gimple_reg (gimple_phi_result (phi)))
{
mark_virtual_phi_result_for_renaming (phi);
remove_phi_node (&gsi, true);
continue;
}
- if (!e2)
- {
- op = gimple_phi_arg_def (phi, e->dest_idx == 0 ? 1 : 0);
- locus = gimple_phi_arg_location (phi, e->dest_idx == 0 ? 1 : 0);
- }
- else
+
+ /* Dead PHI do not imply control dependency. */
+ if (!gimple_plf (phi, STMT_NECESSARY))
{
- op = gimple_phi_arg_def (phi, e2->dest_idx);
- locus = gimple_phi_arg_location (phi, e2->dest_idx);
+ gsi_next (&gsi);
+ continue;
}
+
+ op = gimple_phi_arg_def (phi, e2->dest_idx);
+ locus = gimple_phi_arg_location (phi, e2->dest_idx);
add_phi_arg (phi, op, e, locus);
- gcc_assert (e2 || degenerate_phi_p (phi));
+ /* The resulting PHI if not dead can only be degenerate. */
+ gcc_assert (degenerate_phi_p (phi));
gsi_next (&gsi);
}
}
@@ -1041,7 +1006,7 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb)
edge e, e2;
edge_iterator ei;
- post_dom_bb = get_live_post_dom (bb);
+ post_dom_bb = get_immediate_dominator (CDI_POST_DOMINATORS, bb);
e = find_edge (bb, post_dom_bb);