summaryrefslogtreecommitdiffstats
path: root/src/glsl/loop_analysis.cpp
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2013-11-28 11:06:43 -0800
committerPaul Berry <stereotype441@gmail.com>2013-12-09 10:54:20 -0800
commitcb38a0dc0aaa0a5cbc2a5345ecee3c17d9d46987 (patch)
treef3128e66e0d6ab2c4130d84ccfab24532b0701eb /src/glsl/loop_analysis.cpp
parent877db5a792df7f5971c1906a3677b066926b9832 (diff)
downloadexternal_mesa3d-cb38a0dc0aaa0a5cbc2a5345ecee3c17d9d46987.zip
external_mesa3d-cb38a0dc0aaa0a5cbc2a5345ecee3c17d9d46987.tar.gz
external_mesa3d-cb38a0dc0aaa0a5cbc2a5345ecee3c17d9d46987.tar.bz2
glsl: Fix handling of function calls inside nested loops.
Previously, when visiting an ir_call, loop analysis would only mark the innermost enclosing loop as containing a call. As a result, when encountering a loop like this: for (i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { foo(); } } it would incorrectly conclude that the outer loop ran three times. (This is not certain; if foo() modifies i, then the outer loop might run more or fewer times). Fixes piglit test "vs-call-in-nested-loop.shader_test". Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/loop_analysis.cpp')
-rw-r--r--src/glsl/loop_analysis.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp
index b423ad4..c7f9295 100644
--- a/src/glsl/loop_analysis.cpp
+++ b/src/glsl/loop_analysis.cpp
@@ -223,14 +223,14 @@ loop_analysis::visit(ir_loop_jump *ir)
ir_visitor_status
loop_analysis::visit_enter(ir_call *ir)
{
- /* If we're not somewhere inside a loop, there's nothing to do. */
- if (this->state.is_empty())
- return visit_continue;
-
- loop_variable_state *const ls =
- (loop_variable_state *) this->state.get_head();
+ /* Mark every loop that we're currently analyzing as containing an ir_call
+ * (even those at outer nesting levels).
+ */
+ foreach_list(node, &this->state) {
+ loop_variable_state *const ls = (loop_variable_state *) node;
+ ls->contains_calls = true;
+ }
- ls->contains_calls = true;
return visit_continue_with_parent;
}