aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-09 10:39:43 +0100
committermarha <marha@users.sourceforge.net>2012-03-09 10:39:43 +0100
commitf7eb7329c8efe023b304d5e66b08d1a998973220 (patch)
tree290de7865db558d7c85ba03e735e4a135ae69aab /mesalib/src/glsl
parentceca11a64938e803d2e0d8ccfc030357c3a0121c (diff)
parentd483a0007d3a25fbf565436f655fa45b4265628a (diff)
downloadvcxsrv-f7eb7329c8efe023b304d5e66b08d1a998973220.tar.gz
vcxsrv-f7eb7329c8efe023b304d5e66b08d1a998973220.tar.bz2
vcxsrv-f7eb7329c8efe023b304d5e66b08d1a998973220.zip
Merge remote-tracking branch 'origin/released'
Conflicts: libxcb/src/xcb_in.c
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/loop_unroll.cpp48
1 files changed, 36 insertions, 12 deletions
diff --git a/mesalib/src/glsl/loop_unroll.cpp b/mesalib/src/glsl/loop_unroll.cpp
index d0bcaa670..3434fde62 100644
--- a/mesalib/src/glsl/loop_unroll.cpp
+++ b/mesalib/src/glsl/loop_unroll.cpp
@@ -50,13 +50,44 @@ is_break(ir_instruction *ir)
&& ((ir_loop_jump *) ir)->is_break();
}
+class loop_unroll_count : public ir_hierarchical_visitor {
+public:
+ int nodes;
+ bool fail;
+
+ loop_unroll_count(exec_list *list)
+ {
+ nodes = 0;
+ fail = false;
+
+ run(list);
+ }
+
+ virtual ir_visitor_status visit_enter(ir_assignment *ir)
+ {
+ nodes++;
+ return visit_continue;
+ }
+
+ virtual ir_visitor_status visit_enter(ir_expression *ir)
+ {
+ nodes++;
+ return visit_continue;
+ }
+
+ virtual ir_visitor_status visit_enter(ir_loop *ir)
+ {
+ fail = true;
+ return visit_continue;
+ }
+};
+
ir_visitor_status
loop_unroll_visitor::visit_leave(ir_loop *ir)
{
loop_variable_state *const ls = this->state->get(ir);
int iterations;
- unsigned ir_count;
/* If we've entered a loop that hasn't been analyzed, something really,
* really bad has happened.
@@ -81,17 +112,10 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
/* Don't try to unroll nested loops and loops with a huge body.
*/
- ir_count = 0;
- foreach_list(node, &ir->body_instructions) {
- ++ir_count;
-
- /* If the loop body gets to huge, do not unroll. */
- if (5*max_iterations < ir_count*iterations)
- return visit_continue;
- /* Do not unroll loops with child loop nodes. */
- if (((ir_instruction *) node)->as_loop())
- return visit_continue;
- }
+ loop_unroll_count count(&ir->body_instructions);
+
+ if (count.fail || count.nodes * iterations > (int)max_iterations * 5)
+ return visit_continue;
if (ls->num_loop_jumps > 1)
return visit_continue;