end block can not be optimized away any more.
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Tue, 13 Mar 2001 07:50:21 +0000 (07:50 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Tue, 13 Mar 2001 07:50:21 +0000 (07:50 +0000)
[r130]

ir/ir/ircons.c
ir/ir/irgopt.c
ir/ir/iropt.c
testprograms/Makefile.in
testprograms/if_while_example.c
testprograms/while_example.c

index 09eda52..5015199 100644 (file)
@@ -1227,6 +1227,7 @@ mature_block (ir_node *block)
     /* 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. **/
index 9f4c1a9..751ad2a 100644 (file)
@@ -158,8 +158,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);
+       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.
index d668c6a..6a42358 100644 (file)
@@ -270,10 +270,12 @@ equivalent_node (ir_node *n)
          && 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;
        }
index 53cf327..f9914d1 100644 (file)
@@ -17,7 +17,7 @@ SOURCES := Makefile.in \
        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=;)
index 33991b6..a58acba 100644 (file)
@@ -20,7 +20,7 @@
 ***    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;
index e931c35..3c19927 100644 (file)
@@ -16,7 +16,7 @@
 ***    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;
@@ -72,7 +72,7 @@ main(void)
   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);
@@ -83,9 +83,9 @@ main(void)
   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));