remove self referencing blocks if cf is Cond
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 18 Jun 2004 11:54:12 +0000 (11:54 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 18 Jun 2004 11:54:12 +0000 (11:54 +0000)
[r3156]

ir/ir/irgopt.c
ir/ir/iropt.c

index cea4a39..5609868 100644 (file)
@@ -1662,7 +1662,6 @@ static void merge_blocks(ir_node *n, void *env) {
       b = new_node;
       new_node = equivalent_node(b);
     }
-    /* GL @@@ get_opt_normalize hinzugefuegt, 5.5.2003 */
     if (is_Bad(new_node) && get_opt_normalize()) exchange(n, new_Bad());
   }
 }
@@ -1680,7 +1679,7 @@ static void collect_nodes(ir_node *n, void *env) {
       /* Collect Phi nodes to compact ins along with block's ins. */
       set_irn_link(n, get_irn_link(b));
       set_irn_link(b, n);
-    } else if (get_irn_op(n) != op_Jmp) {  /* Check for non empty block. */
+    } else if ((get_irn_op(n) != op_Jmp) && !is_Bad(b)) {  /* Check for non empty block. */
       mark_Block_block_visited(b);
     }
   }
index f7d6fee..a46b83d 100644 (file)
@@ -494,15 +494,19 @@ static ir_node *equivalent_node_Block(ir_node *n)
      This should be true, as the block is matured before optimize is called.
      But what about Phi-cycles with the Phi0/Id that could not be resolved?
      Remaining Phi nodes are just Ids. */
-  if ((get_Block_n_cfgpreds(n) == 1) &&
-      (get_irn_op(get_Block_cfgpred(n, 0)) == op_Jmp) &&
-      (get_opt_control_flow_straightening())) {
-    n = get_nodes_Block(get_Block_cfgpred(n, 0));
-    if (n == oldn) {
-      /* Jmp jumps into the block it is in -- deal self cycle. */
+  if (get_Block_n_cfgpreds(n) == 1) {
+    ir_node *cfgpred = skip_Proj(get_Block_cfgpred(n, 0));
+    ir_node *predblock = get_nodes_Block(cfgpred);
+    if (get_irn_op(cfgpred) == op_Jmp) {
+      if (predblock == oldn) {
+       /* Jmp jumps into the block it is in -- deal self cycle. */
+       n = new_Bad();                                      DBG_OPT_DEAD;
+      } else if (get_opt_control_flow_straightening()) {
+       n = predblock;                                      DBG_OPT_STG;
+      }
+    } else if ((get_irn_op(cfgpred) == op_Cond) && (predblock == oldn)) {
+      /* Cond jumps into the block it is in -- deal self cycle. */
       n = new_Bad();                                      DBG_OPT_DEAD;
-    } else {
-                                                          DBG_OPT_STG;
     }
 
   } else if ((get_Block_n_cfgpreds(n) == 2) &&