summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2011-01-17 22:07:55 -0800
committerEric Anholt <eric@anholt.net>2011-01-18 10:17:37 -0800
commit58c988ada56114b56477983f66b4039219f1a82c (patch)
tree0599f47a88746a3176894b9b492ade28bf5f37ed /src
parent754b9c5363aa7ae5f47c88c78790b3fe35c07403 (diff)
glsl: Skip the rest of loop unrolling if no loops were found.
Shaves 1.6% (+/- 1.0%) off of ff_fragment_shader glean texCombine time (n=5).
Diffstat (limited to 'src')
-rw-r--r--src/glsl/glsl_parser_extras.cpp6
-rw-r--r--src/glsl/loop_analysis.cpp3
-rw-r--r--src/glsl/loop_analysis.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index cbeacd5633..77885d4e1e 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -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;
diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp
index ff7adf00a2..3cf86ebaa3 100644
--- a/src/glsl/loop_analysis.cpp
+++ b/src/glsl/loop_analysis.cpp
@@ -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;
}
diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h
index 7b0511fbbe..229730836a 100644
--- a/src/glsl/loop_analysis.h
+++ b/src/glsl/loop_analysis.h
@@ -214,6 +214,8 @@ public:
loop_variable_state *insert(ir_loop *ir);
+ bool loop_found;
+
private:
loop_state();