Let some optimizations return non-zero, if they changed something (for fixpoint itera...
authorMoritz Kroll <Moritz.Kroll@gmx.de>
Sun, 5 Oct 2008 00:44:22 +0000 (00:44 +0000)
committerMoritz Kroll <Moritz.Kroll@gmx.de>
Sun, 5 Oct 2008 00:44:22 +0000 (00:44 +0000)
[r22486]

include/libfirm/irgopt.h
include/libfirm/iroptimize.h
ir/ir/irgopt.c
ir/opt/convopt.c
ir/opt/ldstopt.c
ir/opt/reassoc.c
vc2005/libfirm.vcproj

index aeaf02c..dac94fd 100644 (file)
@@ -39,20 +39,22 @@ void local_optimize_node(ir_node *n);
  * @param irg  The graph to be optimized.
  *
  * After applying local_optimize_graph() to a IR-graph, Bad nodes
- * only occure as predecessor of Block and Phi nodes.
+ * only occur as predecessor of Block and Phi nodes.
  */
 void local_optimize_graph(ir_graph *irg);
 
 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
  *
- * @param irg  The graph to be optimized.
+ * After applying optimize_graph_df() to a IR-graph, Bad nodes
+ * only occur as predecessor of Block and Phi nodes.
  *
- * After applying local_optimize_graph() to a IR-graph, Bad nodes
- * only occure as predecessor of Block and Phi nodes.
+ * This version uses fixpoint iteration.
+ *
+ * @param irg  The graph to be optimized.
  *
- * This version used a fixpoint iteration.
+ * @return non-zero if the optimization could be applied, 0 else
  */
-void optimize_graph_df(ir_graph *irg);
+int optimize_graph_df(ir_graph *irg);
 
 /** Performs dead node elimination by copying the ir graph to a new obstack.
  *
index 44edd02..61103da 100644 (file)
@@ -63,8 +63,10 @@ void opt_bool(ir_graph *irg);
  * Try to reduce the number of conv nodes in the given ir graph.
  *
  * @param irg  the graph
+ *
+ * @return non-zero if the optimization could be applied, 0 else
  */
-void conv_opt(ir_graph *irg);
+int conv_opt(ir_graph *irg);
 
 /**
  * Do the scalar replacement optimization.
@@ -235,8 +237,10 @@ ir_node *can_replace_load_by_const(const ir_node *load, ir_node *c);
  *
  * Store after Load: A Store after a Load is removed, if the
  *   Store doesn't have an exception handler.
+ *
+ * @return non-zero if the optimization could be applied, 0 else
  */
-void optimize_load_store(ir_graph *irg);
+int optimize_load_store(ir_graph *irg);
 
 /**
  * Do Loop unrolling in the given graph.
@@ -372,9 +376,9 @@ void proc_cloning(float threshold);
  * See Muchnik 12.3.1 Algebraic Simplification and Reassociation of
  * Addressing Expressions.
  *
- *
+ * @return non-zero if the optimization could be applied, 0 else
  */
-void optimize_reassociation(ir_graph *irg);
+int optimize_reassociation(ir_graph *irg);
 
 /**
  * Normalize the Returns of a graph by creating a new End block
index 207c922..ed97380 100644 (file)
@@ -166,11 +166,11 @@ static void opt_walker(ir_node *n, void *env) {
 }
 
 /* Applies local optimizations to all nodes in the graph until fixpoint. */
-void optimize_graph_df(ir_graph *irg) {
+int optimize_graph_df(ir_graph *irg) {
        pdeq     *waitq = new_pdeq();
        ir_graph *rem = current_ir_graph;
        ir_node  *end;
-       int      i, state, n_ka;
+       int      i, state, n_ka, changed;
 
        current_ir_graph = irg;
 
@@ -220,6 +220,10 @@ void optimize_graph_df(ir_graph *irg) {
        set_irg_visited(current_ir_graph, get_irg_visited(irg) - 1);
        irg_walk(get_irg_end(irg), NULL, opt_walker, waitq);
 
+       /* any optimized nodes are stored in the wait queue,
+        * so if it's not empty, the graph has been changed */
+       changed = !pdeq_empty(waitq);
+
        /* finish the wait queue */
        while (! pdeq_empty(waitq)) {
                ir_node *n = pdeq_getl(waitq);
@@ -235,4 +239,5 @@ void optimize_graph_df(ir_graph *irg) {
                edges_deactivate(irg);
 
        current_ir_graph = rem;
+       return changed;
 }
index 354c2d5..09b5cd7 100644 (file)
@@ -274,7 +274,7 @@ void conv_opt_walker(ir_node *node, void *data)
        }
 }
 
-void conv_opt(ir_graph *irg)
+int conv_opt(ir_graph *irg)
 {
        char invalidate = 0;
        FIRM_DBG_REGISTER(dbg, "firm.opt.conv");
@@ -292,4 +292,5 @@ void conv_opt(ir_graph *irg)
        if (invalidate) {
                set_irg_outs_inconsistent(irg);
        }
+       return invalidate;
 }
index 4c29efa..2ef7cec 100644 (file)
@@ -2211,7 +2211,7 @@ static int optimize_loops(ir_graph *irg) {
 /*
  * do the load store optimization
  */
-void optimize_load_store(ir_graph *irg) {
+int optimize_load_store(ir_graph *irg) {
        walk_env_t env;
 
        FIRM_DBG_REGISTER(dbg, "firm.opt.ldstopt");
@@ -2258,4 +2258,5 @@ void optimize_load_store(ir_graph *irg) {
                have Bad() predecessors. */
                set_irg_doms_inconsistent(irg);
        }
+       return (int) env.changes;
 }  /* optimize_load_store */
index 28b4526..5bcdbb9 100644 (file)
@@ -872,7 +872,7 @@ static void reverse_rules(ir_node *node, void *env) {
 /*
  * do the reassociation
  */
-void optimize_reassociation(ir_graph *irg)
+int optimize_reassociation(ir_graph *irg)
 {
        walker_t env;
        irg_loopinfo_state state;
@@ -931,6 +931,7 @@ void optimize_reassociation(ir_graph *irg)
 
        del_waitq(env.wq);
        current_ir_graph = rem;
+       return env.changes;
 }  /* optimize_reassociation */
 
 /* Sets the default reassociation operation for an ir_op_ops. */
index a65f6eb..033d4d8 100644 (file)
                                                />
                                        </FileConfiguration>
                                </File>
+                               <File
+                                       RelativePath="..\ir\adt\array_t.h"
+                                       >
+                               </File>
                                <File
                                        RelativePath="..\ir\adt\bipartite.c"
                                        >
                                                />
                                        </FileConfiguration>
                                </File>
-                               <File
-                                       RelativePath="..\ir\ir\irflag_t.def"
-                                       >
-                                       <FileConfiguration
-                                               Name="Release|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCustomBuildTool"
-                                               />
-                                       </FileConfiguration>
-                                       <FileConfiguration
-                                               Name="Debug|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCustomBuildTool"
-                                               />
-                                       </FileConfiguration>
-                                       <FileConfiguration
-                                               Name="DebugJTEST|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCustomBuildTool"
-                                               />
-                                       </FileConfiguration>
-                               </File>
                                <File
                                        RelativePath="..\ir\ir\irflag_t.h"
                                        >