summaryrefslogtreecommitdiffstats
path: root/src/glsl/loop_controls.cpp
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2013-11-29 00:11:12 -0800
committerPaul Berry <stereotype441@gmail.com>2013-12-09 10:55:03 -0800
commit4d844cfa56220b7de8ca676ad222d89f81c60c09 (patch)
tree0b5fa5d797cccbc63f94a7add09549b7d1d2f2a5 /src/glsl/loop_controls.cpp
parente734c9f677ef3e9e2e4f207e4e794651ea6643b4 (diff)
glsl/loops: Get rid of loop_variable_state::max_iterations.
This value is now redundant with loop_variable_state::limiting_terminator->iterations and ir_loop::normative_bound. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/loop_controls.cpp')
-rw-r--r--src/glsl/loop_controls.cpp41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index a14ea6ba6be..9e32ff5d5fa 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -183,24 +183,23 @@ loop_control_visitor::visit_leave(ir_loop *ir)
return visit_continue;
}
- /* Figure out how many times the loop will run based on the iteration count
- * annotations made by loop analysis, and give the loop a normative bound
- * if possible.
- */
- unsigned max_iterations =
- ls->max_iterations < 0 ? INT_MAX : ls->max_iterations;
-
- if (ir->normative_bound >= 0)
- max_iterations = ir->normative_bound;
+ if (ls->limiting_terminator != NULL) {
+ /* If the limiting terminator has an iteration count of zero, then we've
+ * proven that the loop cannot run, so delete it.
+ */
+ int iterations = ls->limiting_terminator->iterations;
+ if (iterations == 0) {
+ ir->remove();
+ this->progress = true;
+ return visit_continue;
+ }
- /* If the limiting terminator has a lower iteration count than we'd
- * previously inferred for this loop, then make the new iteration count the
- * normative bound for this loop.
- */
- if (ls->limiting_terminator != NULL &&
- (unsigned) ls->limiting_terminator->iterations < max_iterations) {
- ir->normative_bound = ls->limiting_terminator->iterations;
- max_iterations = ls->limiting_terminator->iterations;
+ /* If the limiting terminator has a lower iteration count than the
+ * normative loop bound (if any), then make this a normatively bounded
+ * loop with the new iteration count.
+ */
+ if (ir->normative_bound < 0 || iterations < ir->normative_bound)
+ ir->normative_bound = iterations;
}
/* Remove the conditional break statements associated with all terminators
@@ -221,14 +220,6 @@ loop_control_visitor::visit_leave(ir_loop *ir)
this->progress = true;
}
- /* If we have proven the one of the loop exit conditions is satisifed before
- * running the loop once, remove the loop.
- */
- if (max_iterations == 0)
- ir->remove();
- else
- ls->max_iterations = max_iterations;
-
return visit_continue;
}