Commit 32fc212e authored by Matthias Braun's avatar Matthias Braun
Browse files

also do unreachable code elimination during gcse

parent 2371a569
......@@ -187,16 +187,16 @@ int optimize_graph_df(ir_graph *irg)
if (get_opt_global_cse()) {
set_irg_pinned(irg, op_pin_state_floats);
} else {
/* The following enables unreachable code elimination (=Blocks may be
* Bad). We cannot enable it in global_cse nodes since we can't
* determine a nodes block there and therefore can't remove all code
* in unreachable blocks */
set_irg_state(irg, IR_GRAPH_STATE_BAD_BLOCK);
if (get_irg_dom_state(irg) == dom_consistent)
irg_block_walk_graph(irg, NULL, kill_dead_blocks, NULL);
}
/* The following enables unreachable code elimination (=Blocks may be
* Bad). We cannot enable it in global_cse nodes since we can't
* determine a nodes block there and therefore can't remove all code
* in unreachable blocks */
set_irg_state(irg, IR_GRAPH_STATE_BAD_BLOCK);
if (get_irg_dom_state(irg) == dom_consistent)
irg_block_walk_graph(irg, NULL, kill_dead_blocks, NULL);
/* invalidate info */
set_irg_outs_inconsistent(irg);
set_irg_doms_inconsistent(irg);
......
......@@ -6274,10 +6274,8 @@ static ir_node *gigo(ir_node *node)
{
ir_op *op = get_irn_op(node);
/* Nodes in bad blocks are bad.
* Beware: we can only read the block of a non-floating node. */
if (op != op_Block && is_irn_pinned_in_irg(node)
&& is_Bad(get_nodes_block(node))) {
/* Code in "Bad" blocks is unreachable and can be replaced by Bad */
if (op != op_Block && is_Bad(get_nodes_block(node))) {
ir_graph *irg = get_irn_irg(node);
return get_irg_bad(irg);
}
......@@ -6304,7 +6302,7 @@ static ir_node *gigo(ir_node *node)
}
return node;
} /* gigo */
}
/**
* These optimizations deallocate nodes from the obstack.
......
......@@ -45,14 +45,6 @@ static bool is_block_reachable(ir_node *block)
return get_Block_dom_depth(block) >= 0;
}
/* mark node as not-visited */
static void clear_irn_visited(ir_node *node)
{
ir_graph *irg = get_irn_irg(node);
ir_visited_t visited = get_irg_visited(irg);
set_irn_visited(node, visited-1);
}
/**
* Find the earliest correct block for node n. --- Place n into the
* same Block as its dominance-deepest Input.
......@@ -112,20 +104,7 @@ static void place_floats_early(ir_node *n, waitq *worklist)
arity = get_irn_arity(n);
place_floats_early(block, worklist);
for (i = 0; i < arity; ++i) {
ir_node *pred = get_irn_n(n, i);
ir_node *pred_block = get_nodes_block(pred);
/* gcse can lead to predecessors of reachable code being unreachable.
* Move them into the current block in this case */
if (!is_block_reachable(pred_block)) {
ir_node *new_pred_block = block;
assert(get_irn_pinned(pred) == op_pin_state_floats);
if (is_Phi(n)) {
new_pred_block = get_Block_cfgpred_block(block, i);
}
set_nodes_block(pred, new_pred_block);
clear_irn_visited(pred);
}
ir_node *pred = get_irn_n(n, i);
place_floats_early(pred, worklist);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment