end block can not be optimized away any more.
[libfirm] / ir / ir / iropt.c
index c85202c..6a42358 100644 (file)
@@ -6,6 +6,10 @@
 ** iropt --- optimizations intertwined with IR construction.
 */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 # include "irnode_t.h"
 # include "irgraph_t.h"
 # include "iropt_t.h"
@@ -266,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;
        }
@@ -710,7 +716,7 @@ transform_node (ir_node *n)
   return n;
 }
 
-/***************** Common Subexpression Elimination *****************/
+/* **************** Common Subexpression Elimination **************** */
 
 /* Compare function for two nodes in the hash table.   Gets two     */
 /* nodes as parameters.                                             */
@@ -1002,7 +1008,7 @@ optimize_in_place (ir_node *n)
   }
 
   /* remove unnecessary nodes */
-  //if (get_opt_constant_folding())
+  /*if (get_opt_constant_folding()) */
   if (get_opt_constant_folding() || get_irn_op(n) == op_Phi)
     n = equivalent_node (n);