- /*
- * BEWARE: do not kill floating notes here as they might be needed in
- * valid blocks because of global CSE.
- */
- if (is_Bad(b) && get_opt_normalize() &&
- get_op_pinned(get_irn_op(n)) == op_pin_state_pinned)
- exchange(n, new_Bad());
+/**
+ * Remove cf from dead block by inspecting dominance info
+ * Do not replace blocks by Bad. This optimization shall
+ * ensure, that all Bad cfg preds are removed, and no new
+ * other Bads are introduced.
+ *
+ * Must be run in the post walker.
+ */
+static void remove_dead_block_cf(ir_node *block, void *env)
+{
+ int i, n;
+
+ /* check block predecessors and turn control flow into bad */
+ for (i = 0, n = get_Block_n_cfgpreds(block); i < n; ++i) {
+ ir_node *pred_X = get_Block_cfgpred(block, i);
+
+ if (! is_Bad(pred_X)) {
+ ir_node *pred_bl = get_nodes_block(skip_Proj(pred_X));
+
+ if (is_Bad(pred_bl) || (get_Block_dom_depth(pred_bl) == -1))
+ exchange (pred_X, new_Bad());
+ }