/* turn the dynamic in-array into a static one. */
ins = ARR_LEN (block->in)-1;
NEW_ARR_A (ir_node *, nin, ins);
+ /* @@@ something is strange here... why isn't the array copied? */
/* Traverse a chain of Phi nodes attached to this block and mature
these, too. **/
/* 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);
+ in array contained Bads. Now it's possible, but don't do it for
+ the end block! */
+ if (n != current_ir_graph->end_block) on = optimize_in_place(nn);
+ else on = 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.
&& get_irn_op(get_Block_cfgpred(n, 0)) == op_Jmp) {
n = get_nodes_Block(get_Block_cfgpred(n, 0));
- } else if (n != current_ir_graph->start_block) {
+ } else if ((n != current_ir_graph->start_block) &&
+ (n != current_ir_graph->end_block) ) {
int i;
/* If all inputs are dead, this block is dead too, except if it is
- the start block. This is a step of unreachable code elimination */
+ the start or end block. This is a step of unreachable code
+ elimination */
for (i = 0; i < get_Block_n_cfgpreds(n); i++) {
if (!is_Bad(get_Block_cfgpred(n, i))) break;
}
call_str_example.c if_else_example.c memory_example.c \
cond_example.c if_example.c oo_program_example.c \
const_eval_example.c if_while_example.c three_cfpred_example.c \
- dead_block_example.c inheritance_example.c
+ dead_block_example.c inheritance_example.c while_example.c
bin_EXAMPLES = $(CFILES:.c=)
run_bin_EXAMPLES = $(CFILES:.c=;)
*** if (0 == 0)
*** { a = 2; }
***
-*** while (0 == 0) loop { // 0 == 0 aborts libfirm: Bad pred of Endblock
+*** while (0 == 0) loop {
*** h = a;
*** a = b;
*** b = h;
*** int b = 1; // pos 1
*** int h; // pos 2
***
-*** while (0 == 2) loop { // 0 == 0 will abort libfirm!!
+*** while (0 == 2) loop {
*** h = a;
*** a = b;
*** b = h;
r = new_immBlock ();
add_in_edge (r, x);
x = new_Cond (new_Proj(new_Cmp(new_Const (mode_I, tarval_from_long (mode_i, 0)),
- new_Const (mode_I, tarval_from_long (mode_i, 2))),
+ new_Const (mode_I, tarval_from_long (mode_i, 0))),
mode_b, Eq));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
x = new_Jmp ();
add_in_edge (r, x);
- /* the code in the loop body,
+ /* The code in the loop body,
as we are dealing with local variables only the dataflow edges
- are manipulated */
+ are manipulated. */
set_value (2, get_value (0, mode_I));
set_value (0, get_value (1, mode_I));
set_value (1, get_value (2, mode_I));