Repeat the optimization passes until we stop making progress.
diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp
index a4a67c8..38dee95 100644
--- a/glsl_parser_extras.cpp
+++ b/glsl_parser_extras.cpp
@@ -754,11 +754,16 @@
 
    /* 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 */