From 4d9dd59076e57e746b88a5614e15ab3b071e1d75 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Mon, 12 Feb 2001 17:46:50 +0000 Subject: [PATCH] *** empty log message *** [r87] --- Changes | 4 ++++ ir/ir/irgopt.c | 17 +++++++++++++---- ir/ir/irnode.c | 2 +- ir/ir/iropt.c | 13 +++++++++++-- testprograms/if_else_example.c | 3 ++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index d6f2206d9..4223e8204 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ + 25.1.2001 Goetz + After compacting of in arrays in dead_node_elimination + merge blocks and remove Phis with one pred. + 24.1.2001 Goetz Freeing of obstack in dead_node_elimination commented in. Compacting in arrays of Block and Phi nodes in dead_node_ diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index d9c194708..cc67a354f 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -15,6 +15,7 @@ # include "irgwalk.h" # include "ircons.h" # include "misc.h" +# include "irgmod.h" /********************************************************************/ /* apply optimizations of iropt to all nodes. */ @@ -66,9 +67,9 @@ get_new_node (ir_node * n) /* We use the block_visited flag to mark that we have computed the number of useful predecessors for this block. - Further we encode the new arity in this flag. Remembering the arity is useful, - as it saves a lot of pointer accesses. This function is called for all - Phi and Block nodes in a Block. */ + Further we encode the new arity in this flag. Remembering the arity is + useful, as it saves a lot of pointer accesses. This function is called + for all Phi and Block nodes in a Block. */ inline int compute_new_arity(ir_node *b) { int i, res; @@ -126,7 +127,7 @@ copy_node (ir_node *n, void *env) { Spare the Bad predecessors of Phi and Block nodes. */ inline void copy_preds (ir_node *n, void *env) { - ir_node *nn, *block; + ir_node *nn, *block, *on; int i, j; nn = get_new_node(n); @@ -141,6 +142,10 @@ copy_preds (ir_node *n, void *env) { } /* repair the block visited flag from above misuse */ set_Block_block_visited(nn, 0); + /* Local optimization could not merge two subsequent blocks if + in array contained Bads. Now it's possible. * + on = optimize_in_place(nn); + if (nn != on) exchange(nn, on);*/ } else if (get_irn_opcode(n) == iro_Phi) { /* Don't copy node if corresponding predecessor in block is Bad. The Block itself should not be Bad. */ @@ -152,6 +157,10 @@ copy_preds (ir_node *n, void *env) { set_irn_n (nn, j, get_new_node(get_irn_n(n, i))); j++; } + /* Compacting the Phi's ins might generate Phis with only one + predecessor. * + if (get_irn_arity(n) == 1) + exchange(n, get_irn_n(n, 0)); */ } else { for (i = -1; i < get_irn_arity(n); i++) set_irn_n (nn, i, get_new_node(get_irn_n(n, i))); diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 07ba80435..0aec48fd5 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -1535,7 +1535,7 @@ get_Alloc_size (ir_node *node) { } inline void -set_Allco_size (ir_node *node, ir_node *size) { +set_Alloc_size (ir_node *node, ir_node *size) { assert (node->op == op_Alloc); set_irn_n(node, 1, size); } diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index c55bdb2fa..d58685a1f 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -872,11 +872,20 @@ gigo (ir_node *node) if ( op != op_Block && op != op_Phi && op != op_Tuple) { for (i = -1; i < get_irn_arity(node); i++) { if (is_Bad(get_irn_n(node, i))) { - node = new_Bad(); - break; + return new_Bad(); } } } +#if 0 + /* If Block has only Bads as predecessors it's garbage. */ + /* If Phi has only Bads as predecessors it's garbage. */ + if (op == op_Block || op == op_Phi) { + for (i = 0; i < get_irn_arity(node); i++) { + if (!is_Bad(get_irn_n(node, i))) break; + } + if (i = get_irn_arity(node)) node = new_Bad(); + } +#endif return node; } diff --git a/testprograms/if_else_example.c b/testprograms/if_else_example.c index 3dacb5cf1..21543c4a3 100644 --- a/testprograms/if_else_example.c +++ b/testprograms/if_else_example.c @@ -121,12 +121,13 @@ int main(int argc, char **argv) mature_block (get_irg_end_block(irg)); printf("Optimizing ...\n"); - dead_node_elimination(irg); + //dead_node_elimination(irg); /* verify the graph */ irg_vrfy(irg); printf("Done building the graph. Dumping it.\n"); + //dump_ir_graph (irg); dump_ir_block_graph (irg); printf("use xvcg to view this graph:\n"); printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n"); -- 2.20.1