+ assert(old != nw && "Exchanging node with itself is not allowed");
+ hook_replace(old, nw);
+
+ /*
+ * If new outs are on, we can skip the id node creation and reroute
+ * the edges from the old node to the new directly.
+ */
+ if (edges_activated(current_ir_graph)) {
+ /* copy all dependencies from old to new */
+ add_irn_deps(nw, old);
+
+ edges_reroute(old, nw, current_ir_graph);
+ edges_reroute_kind(old, nw, EDGE_KIND_DEP, current_ir_graph);
+ edges_node_deleted(old, current_ir_graph);
+ old->op = op_Bad;
+ }
+ else {
+ /* 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);