# include "irgwalk.h"
# include "ircons.h"
# include "misc.h"
+# include "irgmod.h"
/********************************************************************/
/* apply optimizations of iropt to all nodes. */
/* 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;
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);
}
/* 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. */
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)));
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;
}
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");