X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fcombo.c;h=66e77693ebece4bacb3720a853b00c0a46ff3ff5;hb=762b472fc81c73cf7a1b0041b8cd286b7206d79d;hp=94c116b74d17875f516e1204f277eda3ade69c65;hpb=15ad7ccd8dff64e1808e1d093d4a8d7cda5af33e;p=libfirm diff --git a/ir/opt/combo.c b/ir/opt/combo.c index 94c116b74..66e77693e 100644 --- a/ir/opt/combo.c +++ b/ir/opt/combo.c @@ -780,7 +780,8 @@ static void init_block_phis(ir_node *irn, void *ctx) (void) ctx; if (is_Phi(irn)) { - add_Block_phi(get_nodes_block(irn), irn); + ir_node *block = get_nodes_block(irn); + add_Block_phi(block, irn); } } /* init_block_phis */ @@ -2257,11 +2258,13 @@ static void compute_Cmp(node_t *node) } else if (r->part == l->part && !mode_is_float(get_irn_mode(l->node))) { tv = relation & ir_relation_equal ? tarval_b_true : tarval_b_false; - /* if the node was ONCE evaluated by all constants, but now + /* if the node was ONCE evaluated to a constant, but now this breaks AND we get from the argument partitions a different - result, switch to bottom. + result, ensure monotony by fall to bottom. This happens because initially all nodes are in the same partition ... */ - if (node->type.tv != tv) + if (node->type.tv == tarval_bottom) + tv = tarval_bottom; + else if (node->type.tv != tv && is_constant_type(node->type)) tv = tarval_bottom; node->type.tv = tv; } else { @@ -2972,6 +2975,11 @@ static int can_exchange(ir_node *pred, ir_node *block) return 0; else if (is_Jmp(pred)) return 1; + else if (is_Raise(pred)) { + /* Raise is a tuple and usually has only one reachable ProjX, + * but it must not be eliminated like a Jmp */ + return 0; + } else if (get_irn_mode(pred) == mode_T) { /* if the predecessor block has more than one reachable outputs we cannot remove the block */ @@ -3001,31 +3009,29 @@ static void apply_cf(ir_node *block, void *ctx) ir_node *pred = get_Block_cfgpred(block, i); if (! is_Bad(pred)) { - node_t *pred_bl = get_irn_node(get_nodes_block(skip_Proj(pred))); - - if (pred_bl->flagged == 0) { - pred_bl->flagged = 3; - - if (pred_bl->type.tv == tarval_reachable) { - /* - * We will remove an edge from block to its pred. - * This might leave the pred block as an endless loop - */ - if (! is_backedge(block, i)) - keep_alive(pred_bl->node); + ir_node *pred_block = get_nodes_block(skip_Proj(pred)); + if (!is_Bad(pred_block)) { + node_t *pred_bl = get_irn_node(pred_block); + + if (pred_bl->flagged == 0) { + pred_bl->flagged = 3; + + if (pred_bl->type.tv == tarval_reachable) { + /* + * We will remove an edge from block to its pred. + * This might leave the pred block as an endless loop + */ + if (! is_backedge(block, i)) + keep_alive(pred_bl->node); + } } } } } - /* the EndBlock is always reachable even if the analysis - finds out the opposite :-) */ - if (block != get_irg_end_block(current_ir_graph)) { - /* mark dead blocks */ - set_Block_dead(block); - DB((dbg, LEVEL_1, "Removing dead %+F\n", block)); - } else { - /* the endblock is unreachable */ + if (block == get_irg_end_block(current_ir_graph)) { + /* Analysis found out that the end block is unreachable, + * hence we remove all its control flow predecessors. */ set_irn_in(block, 0, NULL); } return; @@ -3057,18 +3063,21 @@ static void apply_cf(ir_node *block, void *ctx) } else { DB((dbg, LEVEL_1, "Removing dead input %d from %+F (%+F)\n", i, block, pred)); if (! is_Bad(pred)) { - node_t *pred_bl = get_irn_node(get_nodes_block(skip_Proj(pred))); - - if (pred_bl->flagged == 0) { - pred_bl->flagged = 3; - - if (pred_bl->type.tv == tarval_reachable) { - /* - * We will remove an edge from block to its pred. - * This might leave the pred block as an endless loop - */ - if (! is_backedge(block, i)) - keep_alive(pred_bl->node); + ir_node *pred_block = get_nodes_block(skip_Proj(pred)); + if (!is_Bad(pred_block)) { + node_t *pred_bl = get_irn_node(pred_block); + + if (!is_Bad(pred_bl->node) && pred_bl->flagged == 0) { + pred_bl->flagged = 3; + + if (pred_bl->type.tv == tarval_reachable) { + /* + * We will remove an edge from block to its pred. + * This might leave the pred block as an endless loop + */ + if (! is_backedge(block, i)) + keep_alive(pred_bl->node); + } } } } @@ -3242,7 +3251,9 @@ static void apply_result(ir_node *irn, void *ctx) node_t *block = get_irn_node(get_nodes_block(irn)); if (block->type.tv == tarval_unreachable) { - ir_node *bad = get_irg_bad(current_ir_graph); + ir_graph *irg = get_irn_irg(irn); + ir_mode *mode = get_irn_mode(node->node); + ir_node *bad = new_r_Bad(irg, mode); /* here, bad might already have a node, but this can be safely ignored as long as bad has at least ONE valid node */ @@ -3397,13 +3408,22 @@ static void apply_end(ir_node *end, environment_t *env) /* fix the keep alive */ for (i = j = 0; i < n; i++) { - ir_node *ka = get_End_keepalive(end, i); - node_t *node = get_irn_node(ka); + ir_node *ka = get_End_keepalive(end, i); + ir_node *block; + node_t *node; - if (! is_Block(ka)) - node = get_irn_node(get_nodes_block(ka)); + if (is_Bad(ka)) + continue; + if (!is_Block(ka)) { + block = get_nodes_block(ka); + if (is_Bad(block)) + continue; + } else { + block = ka; + } - if (node->type.tv != tarval_unreachable && !is_Bad(ka)) + node = get_irn_node(block); + if (node->type.tv != tarval_unreachable) in[j++] = ka; } if (j != n) { @@ -3573,10 +3593,8 @@ void combo(ir_graph *irg) if (env.modified) { /* control flow might changed */ - set_irg_outs_inconsistent(irg); set_irg_extblk_inconsistent(irg); set_irg_doms_inconsistent(irg); - set_irg_loopinfo_inconsistent(irg); set_irg_entity_usage_state(irg, ir_entity_usage_not_computed); }