/* 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_ */
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 */
}
}
#endif
+
/* Find first non-self-referencing input */
for (i = 0; i < n_preds; ++i) {
first_val = follow_Id(get_Phi_pred(n, i));
}
/* 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;
}
/* 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) {
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? */
}
/* 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 **/
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);
mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
+
+ local_optimize_graph(irg),
dead_node_elimination(irg);
/* verify the graph */