summaryrefslogtreecommitdiffstats
path: root/src/glsl/loop_analysis.h
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-11-28 10:48:37 -0800
committerPaul Berry <[email protected]>2013-12-09 10:54:16 -0800
commit877db5a792df7f5971c1906a3677b066926b9832 (patch)
tree250784f332ecf754b667012d4ffaa79784cd9ffc /src/glsl/loop_analysis.h
parent2e060551bdfb3f5019f64696f268675a3550927c (diff)
glsl: Fix loop analysis of nested loops.
Previously, when visiting a variable dereference, loop analysis would only consider its effect on the innermost enclosing loop. As a result, when encountering a loop like this: for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { ... i = 2; } } it would incorrectly conclude that the outer loop ran three times. Fixes piglit test "vs-inner-loop-modifies-outer-loop-var.shader_test". Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/loop_analysis.h')
-rw-r--r--src/glsl/loop_analysis.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h
index 4fae829c3ab..3c3719b919e 100644
--- a/src/glsl/loop_analysis.h
+++ b/src/glsl/loop_analysis.h
@@ -167,8 +167,11 @@ public:
/** Are all variables in the RHS of the assignment loop constants? */
bool rhs_clean;
- /** Is there an assignment to the variable that is conditional? */
- bool conditional_assignment;
+ /**
+ * Is there an assignment to the variable that is conditional, or inside a
+ * nested loop?
+ */
+ bool conditional_or_nested_assignment;
/** Reference to the first assignment to the variable in the loop body. */
ir_assignment *first_assignment;
@@ -197,7 +200,7 @@ public:
{
const bool is_const = (this->num_assignments == 0)
|| ((this->num_assignments == 1)
- && !this->conditional_assignment
+ && !this->conditional_or_nested_assignment
&& !this->read_before_write
&& this->rhs_clean);
@@ -214,7 +217,8 @@ public:
return is_const;
}
- void record_reference(bool in_assignee, bool in_conditional_code,
+ void record_reference(bool in_assignee,
+ bool in_conditional_code_or_nested_loop,
ir_assignment *current_assignment);
};