From: Götz Lindenmaier Date: Mon, 12 Feb 2001 21:06:40 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=4cc5088179588002491bc6971b2cfa99898c1963;p=libfirm *** empty log message *** [r88] --- diff --git a/ir/ir/irgopt.h b/ir/ir/irgopt.h index bc5fdc39c..f64f7ecca 100644 --- a/ir/ir/irgopt.h +++ b/ir/ir/irgopt.h @@ -16,7 +16,9 @@ void local_optimize_graph (ir_graph *irg); /* Performs dead node elimination by copying the ir graph to a new obstack. Further removes Bad predecesors from Blocks and the corresponding - inputs to Phi nodes. */ + inputs to Phi nodes. + Attention: the numbers assigned to nodes if the library is compiled for + development/debugging are not conserved by copying. */ void dead_node_elimination(ir_graph *irg); # endif /* _IRGOPT_H_ */ diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index d58685a1f..b4d8e8f50 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -375,6 +375,8 @@ equivalent_node (ir_node *n) themselves. */ int i, n_preds; + + ir_node *block = NULL; /* to shutup gcc */ ir_node *first_val = NULL; /* to shutup gcc */ ir_node *scnd_val = NULL; /* to shutup gcc */ @@ -413,6 +415,7 @@ equivalent_node (ir_node *n) } } #endif + /* Find first non-self-referencing input */ for (i = 0; i < n_preds; ++i) { first_val = follow_Id(get_Phi_pred(n, i)); @@ -426,7 +429,7 @@ equivalent_node (ir_node *n) } /* A totally Bad or self-referencing Phi (we didn't break the above loop) */ - if (i > n_preds) { n = new_Bad(); break; } + if (i >= n_preds) { n = new_Bad(); break; } scnd_val = NULL; @@ -445,8 +448,8 @@ equivalent_node (ir_node *n) } /* Fold, if no multiple distinct non-self-referencing inputs */ - if (i > n_preds) { - n = a; + if (i >= n_preds) { + n = first_val; } else { /* skip the remaining Ids. */ while (++i < n_preds) { @@ -974,6 +977,8 @@ optimize_in_place (ir_node *n) tarval *tv; ir_node *old_n = n; + if (!get_optimize()) return n; + /* if not optimize return n */ if (n == NULL) { /* Here this is possible. Why? */ @@ -995,8 +1000,8 @@ optimize_in_place (ir_node *n) } /* remove unnecessary nodes */ - if (get_opt_constant_folding()) - // if (get_opt_constant_folding() || get_irn_op(n) == op_Phi) + //if (get_opt_constant_folding()) + if (get_opt_constant_folding() || get_irn_op(n) == op_Phi) n = equivalent_node (n); /** common subexpression elimination **/ diff --git a/testprograms/if_while_example.c b/testprograms/if_while_example.c index 19cfd01f1..8078f419f 100644 --- a/testprograms/if_while_example.c +++ b/testprograms/if_while_example.c @@ -43,7 +43,9 @@ main(void) init_firm (); + set_optimize(1); set_opt_constant_folding(0); /* so that the stupid tests are not optimized. */ + /* if 1 aborts ????? @@@ */ set_opt_cse(1); set_opt_dead_node_elimination (1); @@ -126,6 +128,8 @@ main(void) mature_block (get_irg_end_block(irg)); printf("Optimizing ...\n"); + + local_optimize_graph(irg), dead_node_elimination(irg); /* verify the graph */