- moved the imul mem,imm32 splitting into peephole optimizations
[libfirm] / ir / opt / gvn_pre.c
index 36dc90e..87b0725 100644 (file)
@@ -1,25 +1,38 @@
 /*
- * Project:     libFIRM
- * File name:   ir/opt/gvn_pre.c
- * Purpose:     Global Value Numbering Partial Redundancy Elimination
- *              (VanDrunen Hosking 2004)
- * Author:      Michael Beck, Rubino Geiss
- * Created:
- * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2006 Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
 
+/**
+ * @file
+ * @brief   Global Value Numbering Partial Redundancy Elimination
+ *          (VanDrunen Hosking 2004)
+ * @author  Michael Beck, Rubino Geiss
+ * @version $Id$
+ * @summary
+ *
+ * Currently completely broken because our sets do NOT preserve
+ * the topological sort!
+ */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#ifdef HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-#endif
+#include "iroptimize.h"
 
 #include <assert.h>
 
@@ -36,7 +49,7 @@
 #include "ircons.h"
 #include "irgmod.h"
 #include "debug.h"
-#include "gvn_pre.h"
+#include "xmalloc.h"
 
 /** The debug module handle. */
 DEBUG_ONLY(static firm_dbg_module_t *dbg;)
@@ -130,13 +143,16 @@ static int node_set_count(node_set *set) {
   return pset_count(set);
 }
 
+#if 0
 /** computes dst = dst \/ src for node sets */
 static void node_union(node_set *dst, node_set *src)
 {
   ir_node *entry;
-  node_set_foreach(entry, src)
+  node_set_foreach(entry, src) {
     node_add(dst, entry);
+  }
 }
+#endif
 
 /**
  * Lookup a node in a node set.
@@ -165,6 +181,7 @@ static int value_cmp(const void *elt, const void *key, size_t size)
 {
   const value_entry *e1 = elt;
   const value_entry *e2 = key;
+  (void) size;
 
   return identities_cmp(e1->value, e2->value);
 }
@@ -429,15 +446,18 @@ static ir_node *translate(ir_node *node, ir_node *block, int pos, pre_env *env)
        node might depend on that. */
     copy_node_attr(node, nn);
     res = node_add(env->trans_set, nn);
-    if (nn != res)
+    if (nn != res) {
       obstack_free(env->obst, nn);
-    else
+       } else {
       DB((dbg, LEVEL_2, "--> Translate %+F in <%+F,%d> into %+F\n", node, block, pos, res));
+       }
+
     return res;
   }
   return node;
 }
 
+#if 0
 /**
  * Implements phi_translate.
  */
@@ -459,6 +479,7 @@ static ir_node *deep_phi_translate(ir_node *node, ir_node *block, int pos, pre_e
 
   return res;
 }  /* phi_translate */
+#endif
 
 /**
  * Implements phi_translate.
@@ -468,7 +489,6 @@ static ir_node *phi_translate(ir_node *node, ir_node *block, int pos, pre_env *e
   ir_node *nn, *res;
   int i, arity;
   struct obstack *old;
-  ir_node *pred_block = get_Block_cfgpred_block(block, pos);
 
   if (is_Phi(node)) {
     if (get_irn_intra_n(node, -1) == block)
@@ -695,6 +715,7 @@ static void compute_antic(ir_node *block, void *ctx)
   }
 
 //  clean_node_set(info->antic_in, block);
+  (void) clean_node_set;
 
   dump_node_set(info->antic_in, "Antic_in", block);
   if (size != node_set_count(info->antic_in)) {
@@ -774,8 +795,9 @@ static void insert_nodes(ir_node *block, void *ctx)
   value_set_foreach(entry, idom_info->new_set) {
     updated |= value_add_or_replace(curr_info->avail_out, entry->node, entry->value);
   }
-  if (updated)
+  if (updated) {
     dump_value_set(curr_info->avail_out, "Updated [Avail_out]", block);
+  }
 
   if (arity <= 1)
     return;
@@ -958,7 +980,7 @@ static void eliminate_nodes(elim_pair *pairs)
 
 /*
  * Argh: Endless loops cause problems, because the
- * insert algorithm did not terminate. We get tranalated nodes that
+ * insert algorithm did not terminate. We get translated nodes that
  * references the origin. These nodes are translated again and again...
  *
  * The current fix is to use post-dominance. This simple ignores
@@ -972,6 +994,8 @@ void do_gvn_pre(ir_graph *irg)
   block_info *p;
   unsigned antic_iter, insert_iter;
 
+  assert(!"COMPLETELY BROKEN YET, DO NOT USE");
+
   /* register a debug mask */
   FIRM_DBG_REGISTER(dbg, "firm.opt.gvn_pre");
   firm_dbg_set_mask(dbg, SET_LEVEL_2);