From dc467413ce8210e14a6e7157bdbb9307a34afb03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Mon, 12 May 2003 10:25:06 +0000 Subject: [PATCH] Added funcionality in new_Block and new_Phi to construct Blocks in loops. [r1178] --- ir/ir/ircons.c | 11 +++++++++-- ir/ir/ircons.h | 12 +++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 5497c528f..0d4420dda 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -97,6 +97,8 @@ INLINE ir_node * new_rd_Phi (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in, ir_mode *mode) { ir_node *res; + int i; + bool has_unknown = false; assert( get_Block_matured(block) ); assert( get_irn_arity(block) == arity ); @@ -105,7 +107,8 @@ new_rd_Phi (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in res->attr.phi_backedge = new_backedge_arr(irg->obst, arity); - res = optimize_node (res); + for (i = arity-1; i >= 0; i--) if (get_irn_op(in[i]) == op_Unknown) has_unknown = true; + if (!has_unknown) res = optimize_node (res); irn_vrfy_irg (res, irg); /* Memory Phis in endless loops must be kept alive. @@ -938,6 +941,8 @@ ir_node * new_d_Block (dbg_info* db, int arity, ir_node **in) { ir_node *res; + int i; + bool has_unknown = false; res = new_rd_Block (db, current_ir_graph, arity, in); @@ -946,7 +951,9 @@ new_d_Block (dbg_info* db, int arity, ir_node **in) current_ir_graph->n_loc); memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc); - res = optimize_node (res); + for (i = arity-1; i >= 0; i--) if (get_irn_op(in[i]) == op_Unknown) has_unknown = true; + + if (!has_unknown) res = optimize_node (res); current_ir_graph->current_block = res; irn_vrfy_irg (res, current_ir_graph); diff --git a/ir/ir/ircons.h b/ir/ir/ircons.h index 0380d33d6..a5d0f1a2d 100644 --- a/ir/ir/ircons.h +++ b/ir/ir/ircons.h @@ -453,7 +453,12 @@ * -------------------------------------------- * * Creates a new Block with the given list of predecessors. This block - * is mature. + * is mature. As other constructors calls optimization and vrfy for the + * block. If one of the predecessors is Unknown (as it has to be filled in + * later) optimizations are skipped. This is necessary to + * construct Blocks in loops. Leaving Unknown in the Block after finishing + * the construction may have strange effects, especially for interprocedural + * representation and analyses. * * * CONTROL FLOW OPERATIONS @@ -840,6 +845,11 @@ * * Creates a Phi node. The in's order has to correspond to the order * of in's of current_block. This is not checked by the library! + * If one of the predecessors is Unknown (as it has to be filled in + * later) optimizations are skipped. This is necessary to + * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing + * the construction may have strange effects, especially for interprocedural + * representation and analyses. * * Parameter * arity number of predecessors -- 2.20.1