Repeat the optimization passes until we stop making progress.
authorEric Anholt <eric@anholt.net>
Thu, 8 Apr 2010 20:42:48 +0000 (13:42 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 8 Apr 2010 20:43:56 +0000 (13:43 -0700)
glsl_parser_extras.cpp
ir_function_inlining.cpp

index a4a67c88bcb93dc12afad963d712f31e796ccb5e..38dee95c359bd6a3accf42b3b3ade1faa32dce5d 100644 (file)
@@ -754,11 +754,16 @@ main(int argc, char **argv)
 
    /* Optimization passes */
    if (!state.error) {
-      do_function_inlining(&instructions);
+      bool progress;
+      do {
+        progress = false;
 
-      /* Constant folding */
-      ir_constant_folding_visitor constant_folding;
-      visit_exec_list(&instructions, &constant_folding);
+        progress = do_function_inlining(&instructions) || progress;
+
+        /* Constant folding */
+        ir_constant_folding_visitor constant_folding;
+        visit_exec_list(&instructions, &constant_folding);
+      } while (progress);
    }
 
    /* Print out the resulting IR */
index 40f82513095b2c8f856394c140e6a7e286e7b99c..e03673e632df4eca9d0a2661fd7d558e5d00a3b7 100644 (file)
@@ -307,7 +307,7 @@ can_inline(ir_call *call)
 bool
 do_function_inlining(exec_list *instructions)
 {
-   bool progress;
+   bool progress = false;
 
    foreach_iter(exec_list_iterator, iter, *instructions) {
       ir_instruction *ir = (ir_instruction *)iter.get();