From be1efa6eb0ebbf26b6ce0379dc9f99181280f4d3 Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Thu, 10 Feb 2005 10:41:39 +0000 Subject: [PATCH] Exchange can now exploit the always present out edges, if they are activated [r5062] --- ir/ir/irgmod.c | 59 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/ir/ir/irgmod.c b/ir/ir/irgmod.c index 990986f83..06fb0a643 100644 --- a/ir/ir/irgmod.c +++ b/ir/ir/irgmod.c @@ -23,6 +23,7 @@ # include "array.h" # include "ircons.h" # include "irhooks.h" +# include "iredges_t.h" /* Turns a node into a "useless" Tuple. The Tuple just forms a tuple from several inputs. @@ -39,6 +40,7 @@ turn_into_tuple (ir_node *node, int arity) /* Allocate new array, don't free old in_array, it's on the obstack. */ ir_node *block = get_nodes_block(node); node->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, arity+1); + edges_invalidate(node, current_ir_graph); set_nodes_block(node, block); } } @@ -49,26 +51,45 @@ turn_into_tuple (ir_node *node, int arity) void exchange (ir_node *old, ir_node *nw) { - ir_node *block; - ir_graph *irg = get_irn_irg (old); - - assert(old != nw); - assert (irg); - assert(get_irn_op(old)->opar != oparity_dynamic); - - hook_turn_into_id(old); - - block = old->in[0]; - if (!block) { - if (is_Block(nw)) block = nw; - else (block = nw->in[0]); - if (!block) { DDMN(old); DDMN(nw); assert(0 && "cannot find legal block for id"); } - } + /* + * If new outs are on, we can skip the id node creation and reroute + * the edges from the old node to the new directly. + */ +#ifdef FIRM_EDGES_INPLACE + if(edges_activated(current_ir_graph)) { + edges_reroute(old, nw, current_ir_graph); + } + + else +#endif - old->op = op_Id; - old->in = NEW_ARR_D (ir_node *, irg->obst, 2); - old->in[0] = block; - old->in[1] = nw; + /* Else, do it the old-fashioned way. */ + { + ir_graph *irg = get_irn_irg (old); + ir_node *block; + + assert(old != nw); + assert (irg); + assert(get_irn_op(old)->opar != oparity_dynamic); + + hook_turn_into_id(old); + + block = old->in[0]; + if (!block) { + block = is_Block(nw) ? nw : get_nodes_block(nw); + + if (!block) { + DDMN(old); + DDMN(nw); + assert(0 && "cannot find legal block for id"); + } + } + + old->op = op_Id; + old->in = NEW_ARR_D (ir_node *, irg->obst, 2); + old->in[0] = block; + old->in[1] = nw; + } } /*--------------------------------------------------------------------*/ -- 2.20.1