glsl: Skip the rest of loop unrolling if no loops were found.
authorEric Anholt <eric@anholt.net>
Tue, 18 Jan 2011 06:07:55 +0000 (22:07 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 18 Jan 2011 18:17:37 +0000 (10:17 -0800)
Shaves 1.6% (+/- 1.0%) off of ff_fragment_shader glean texCombine time
(n=5).

src/glsl/glsl_parser_extras.cpp
src/glsl/loop_analysis.cpp
src/glsl/loop_analysis.h

index cbeacd5633fe72985b34bdf7ad1d211bd6159301..77885d4e1e37f28923ea5767e4d554608d681ace 100644 (file)
@@ -748,8 +748,10 @@ do_common_optimization(exec_list *ir, bool linked, unsigned max_unroll_iteration
    progress = optimize_redundant_jumps(ir) || progress;
 
    loop_state *ls = analyze_loop_variables(ir);
-   progress = set_loop_controls(ir, ls) || progress;
-   progress = unroll_loops(ir, ls, max_unroll_iterations) || progress;
+   if (ls->loop_found) {
+      progress = set_loop_controls(ir, ls) || progress;
+      progress = unroll_loops(ir, ls, max_unroll_iterations) || progress;
+   }
    delete ls;
 
    return progress;
index ff7adf00a21c920e70fdb1928c85e79e744944d8..3cf86ebaa38dd854ae3ce37d8fab7d6088d2b717 100644 (file)
@@ -38,6 +38,7 @@ loop_state::loop_state()
    this->ht = hash_table_ctor(0, hash_table_pointer_hash,
                              hash_table_pointer_compare);
    this->mem_ctx = talloc_init("loop state");
+   this->loop_found = false;
 }
 
 
@@ -52,7 +53,9 @@ loop_variable_state *
 loop_state::insert(ir_loop *ir)
 {
    loop_variable_state *ls = new(this->mem_ctx) loop_variable_state;
+
    hash_table_insert(this->ht, ls, ir);
+   this->loop_found = true;
 
    return ls;
 }
index 7b0511fbbec915e7157c25399b98a5ccb38250f6..229730836a87039f4e805d339eb7f57671f55f56 100644 (file)
@@ -214,6 +214,8 @@ public:
 
    loop_variable_state *insert(ir_loop *ir);
 
+   bool loop_found;
+
 private:
    loop_state();