*** empty log message ***
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Mon, 12 Feb 2001 21:06:40 +0000 (21:06 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Mon, 12 Feb 2001 21:06:40 +0000 (21:06 +0000)
[r88]

ir/ir/irgopt.h
ir/ir/iropt.c
testprograms/if_while_example.c

index bc5fdc3..f64f7ec 100644 (file)
@@ -16,7 +16,9 @@ void local_optimize_graph (ir_graph *irg);
 
 /* 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_ */
index d58685a..b4d8e8f 100644 (file)
@@ -375,6 +375,8 @@ equivalent_node (ir_node *n)
            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 */
@@ -413,6 +415,7 @@ equivalent_node (ir_node *n)
        }
       }
 #endif
+
       /* Find first non-self-referencing input */
       for (i = 0;  i < n_preds;  ++i) {
         first_val = follow_Id(get_Phi_pred(n, i));
@@ -426,7 +429,7 @@ equivalent_node (ir_node *n)
       }
 
       /* 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;
 
@@ -445,8 +448,8 @@ equivalent_node (ir_node *n)
       }
 
       /* 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) {
@@ -974,6 +977,8 @@ optimize_in_place (ir_node *n)
   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? */
@@ -995,8 +1000,8 @@ optimize_in_place (ir_node *n)
   }
 
   /* 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 **/
index 19cfd01..8078f41 100644 (file)
@@ -43,7 +43,9 @@ main(void)
 
   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);
 
@@ -126,6 +128,8 @@ main(void)
   mature_block (get_irg_end_block(irg));
 
   printf("Optimizing ...\n");
+
+  local_optimize_graph(irg),
   dead_node_elimination(irg);
 
   /* verify the graph */