- /* Clean the value_table in irg for the CSE. */
- del_identities(irg->value_table);
- irg->value_table = new_identities();
-
- 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);
- set_irg_loopinfo_inconsistent(irg);
-
- set_using_irn_link(irg);
-
- end = get_irg_end(irg);
- n_ka = get_End_n_keepalives(end);
-
- /* walk over the graph, but don't touch keep-alives */
- irg_walk(get_irg_end_block(irg), NULL, opt_walker, waitq);
-
- /*
- * Optimize keep-alives by removing superfluous ones.
- * Beware: the last transformation might add new keep-alives
- * that keep blocks that are where visited! So, check only the
- * "old" keep-alives, not the new ones!
- *
- * FIXME: it might be better to completely remove this
- * optimization here ...
- */
- for (i = n_ka - 1; i >= 0; --i) {
- ir_node *ka = get_End_keepalive(end, i);
-
- if (irn_visited(ka) && !is_irn_keep(ka)) {
- /* this node can be regularly visited, no need to keep it */
- set_End_keepalive(end, i, get_irg_bad(irg));
- }
- }
- /* now walk again and visit all not yet visited nodes */
- set_irg_visited(current_ir_graph, get_irg_visited(irg) - 1);
- irg_walk(get_irg_end(irg), NULL, opt_walker, waitq);
-
- /* finish the wait queue */
- while (! pdeq_empty(waitq)) {
- ir_node *n = pdeq_getl(waitq);
- if (! is_Bad(n))
+ /* enable unreachable code elimination */
+ assert(!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE));
+ add_irg_constraints(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE);
+
+ new_identities(irg);
+ assure_edges(irg);
+ assure_doms(irg);
+
+
+ ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
+ irg_walk_graph(irg, NULL, opt_walker, waitq);
+
+ /* any optimized nodes are stored in the wait queue,
+ * so if it's not empty, the graph has been changed */
+ while (!pdeq_empty(waitq)) {
+ /* finish the wait queue */
+ while (! pdeq_empty(waitq)) {
+ ir_node *n = (ir_node*)pdeq_getl(waitq);