From e00b93a1f7b4bc7f5e887591c000524e13f80826 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Thu, 28 Nov 2013 08:13:41 -0800 Subject: glsl/loops: replace loop controls with a normative bound. This patch replaces the ir_loop fields "from", "to", "increment", "counter", and "cmp" with a single integer ("normative_bound") that serves the same purpose. I've used the name "normative_bound" to emphasize the fact that the back-end is required to emit code to prevent the loop from running more than normative_bound times. (By contrast, an "informative" bound would be a bound that is informational only). Reviewed-by: Jordan Justen Reviewed-by: Ian Romanick --- src/glsl/loop_controls.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/glsl/loop_controls.cpp') diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index 0eb103f49b..a1dc20e719 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -187,13 +187,11 @@ loop_control_visitor::visit_leave(ir_loop *ir) * i is a loop induction variable, c is a constant, and < is any relative * operator. */ - int max_iterations = ls->max_iterations; + unsigned max_iterations = + ls->max_iterations < 0 ? INT_MAX : ls->max_iterations; - if(ir->from && ir->to && ir->increment) - max_iterations = calculate_iterations(ir->from, ir->to, ir->increment, (ir_expression_operation)ir->cmp); - - if(max_iterations < 0) - max_iterations = INT_MAX; + if (ir->normative_bound >= 0) + max_iterations = ir->normative_bound; foreach_list(node, &ls->terminators) { loop_terminator *t = (loop_terminator *) node; @@ -248,14 +246,11 @@ loop_control_visitor::visit_leave(ir_loop *ir) cmp); if (iterations >= 0) { /* If the new iteration count is lower than the previously - * believed iteration count, update the loop control values. + * believed iteration count, then add a normative bound to + * this loop. */ - if (iterations < max_iterations) { - ir->from = init->clone(ir, NULL); - ir->to = limit->clone(ir, NULL); - ir->increment = lv->increment->clone(ir, NULL); - ir->counter = lv->var->clone(ir, NULL); - ir->cmp = cmp; + if ((unsigned) iterations < max_iterations) { + ir->normative_bound = iterations; max_iterations = iterations; } -- cgit v1.2.3