From: Paul Berry Date: Thu, 28 Nov 2013 16:13:41 +0000 (-0800) Subject: glsl/loops: replace loop controls with a normative bound. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e00b93a1f7b4bc7f5e887591c000524e13f80826;p=mesa.git 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 --- diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 330b4dccbb5..29fe64ad496 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1277,11 +1277,7 @@ ir_constant::is_basis() const ir_loop::ir_loop() { this->ir_type = ir_type_loop; - this->cmp = ir_unop_neg; - this->from = NULL; - this->to = NULL; - this->increment = NULL; - this->counter = NULL; + this->normative_bound = -1; } diff --git a/src/glsl/ir.h b/src/glsl/ir.h index e60ffc0834f..a34a9c3193b 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -86,6 +86,7 @@ enum ir_node_type { ir_type_max /**< maximum ir_type enum number, for validation */ }; + /** * Base class of all IR instructions */ @@ -1025,54 +1026,11 @@ public: exec_list body_instructions; /** - * \name Loop counter and controls - * - * Represents a loop like a FORTRAN \c do-loop. - * - * \note - * If \c from and \c to are the same value, the loop will execute once. - */ - /*@{*/ - - /** - * Value which should be assigned to \c counter before the first iteration - * of the loop. Must be non-null whenever \c counter is non-null, and vice - * versa. - */ - ir_rvalue *from; - - /** - * Value which \c counter should be compared to in order to determine - * whether to exit the loop. Must be non-null whenever \c counter is - * non-null, and vice versa. + * Normative bound for the loop. If this value is >= 0, the back-end + * should generate instructions to ensure that the loop executes no more + * than this many times. */ - ir_rvalue *to; - - /** - * Value which should be added to \c counter at the end of each loop - * iteration. Must be non-null whenever \c counter is non-null, and vice - * versa. - */ - ir_rvalue *increment; - - /** - * Variable which counts loop iterations. This is a brand new ir_variable - * declaration (not a reference to a previously declared ir_variable, as in - * ir_dereference_variable). - */ - ir_variable *counter; - - /** - * Comparison operation in the loop terminator. - * - * If any of the loop control fields are non-\c NULL, this field must be - * one of \c ir_binop_less, \c ir_binop_greater, \c ir_binop_lequal, - * \c ir_binop_gequal, \c ir_binop_equal, or \c ir_binop_nequal. - * - * Ignored if \c counter is NULL. - */ - int cmp; - /*@}*/ + int normative_bound; }; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index a66864a61d1..383627ae3e2 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -158,21 +158,13 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const { ir_loop *new_loop = new(mem_ctx) ir_loop(); - if (this->from) - new_loop->from = this->from->clone(mem_ctx, ht); - if (this->to) - new_loop->to = this->to->clone(mem_ctx, ht); - if (this->increment) - new_loop->increment = this->increment->clone(mem_ctx, ht); - if (this->counter) - new_loop->counter = this->counter->clone(mem_ctx, ht); + new_loop->normative_bound = this->normative_bound; foreach_iter(exec_list_iterator, iter, this->body_instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht)); } - new_loop->cmp = this->cmp; return new_loop; } diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index a0fe3b95d35..2a1f70e5baa 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -87,36 +87,10 @@ ir_loop::accept(ir_hierarchical_visitor *v) if (s != visit_continue) return (s == visit_continue_with_parent) ? visit_continue : s; - if (this->counter) { - s = this->counter->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - s = visit_list_elements(v, &this->body_instructions); if (s == visit_stop) return s; - if (s != visit_continue_with_parent) { - if (this->from) { - s = this->from->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->to) { - s = this->to->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->increment) { - s = this->increment->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - } - return v->visit_leave(this); } diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index f4109fb1f4c..857a27ad21f 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -524,17 +524,8 @@ void ir_print_visitor::visit(ir_loop *ir) { printf("(loop ("); - if (ir->counter != NULL) - ir->counter->accept(this); - printf(") ("); - if (ir->from != NULL) - ir->from->accept(this); - printf(") ("); - if (ir->to != NULL) - ir->to->accept(this); - printf(") ("); - if (ir->increment != NULL) - ir->increment->accept(this); + if (ir->normative_bound >= 0) + printf("%d", ir->normative_bound); printf(") (\n"); indentation++; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 7fcb34d2390..72ce684b69c 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -488,18 +488,34 @@ ir_reader::read_if(s_expression *expr, ir_loop *loop_ctx) ir_loop * ir_reader::read_loop(s_expression *expr) { - s_expression *s_counter, *s_from, *s_to, *s_inc, *s_body; + s_expression *s_bound_expr, *s_body, *s_bound; - s_pattern pat[] = { "loop", s_counter, s_from, s_to, s_inc, s_body }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (loop " - " )"); + s_pattern loop_pat[] = { "loop", s_bound_expr, s_body }; + s_pattern no_bound_pat[] = { }; + s_pattern bound_pat[] = { s_bound }; + if (!MATCH(expr, loop_pat)) { + ir_read_error(expr, "expected (loop )"); return NULL; } - // FINISHME: actually read the count/from/to fields. - ir_loop *loop = new(mem_ctx) ir_loop; + + if (MATCH(s_bound_expr, no_bound_pat)) { + loop->normative_bound = -1; + } else if (MATCH(s_bound_expr, bound_pat)) { + s_int *value = SX_AS_INT(s_bound); + if (value == NULL) { + ir_read_error(s_bound_expr, "malformed loop bound"); + delete loop; + return NULL; + } + loop->normative_bound = value->value(); + } else { + ir_read_error(s_bound_expr, "malformed loop bound"); + delete loop; + return NULL; + } + read_instructions(&loop->body_instructions, s_body, loop); if (state->error) { delete loop; diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 26d63883422..8e73229572d 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -63,8 +63,6 @@ public: virtual ir_visitor_status visit_enter(ir_if *ir); - virtual ir_visitor_status visit_enter(ir_loop *ir); - virtual ir_visitor_status visit_leave(ir_loop *ir); virtual ir_visitor_status visit_enter(ir_function *ir); virtual ir_visitor_status visit_leave(ir_function *ir); virtual ir_visitor_status visit_enter(ir_function_signature *ir); @@ -149,54 +147,6 @@ ir_validate::visit_enter(ir_if *ir) } -ir_visitor_status -ir_validate::visit_enter(ir_loop *ir) -{ - if (ir->counter != NULL && hash_table_find(ht, ir->counter) != NULL) { - printf("ir_loop @ %p specifies already-declared variable `%s' @ %p\n", - (void *) ir, ir->counter->name, (void *) ir->counter); - abort(); - } - return visit_continue; -} - - -ir_visitor_status -ir_validate::visit_leave(ir_loop *ir) -{ - if (ir->counter != NULL) { - if ((ir->from == NULL) || (ir->to == NULL) || (ir->increment == NULL)) { - printf("ir_loop has invalid loop controls:\n" - " counter: %p\n" - " from: %p\n" - " to: %p\n" - " increment: %p\n", - (void *) ir->counter, (void *) ir->from, (void *) ir->to, - (void *) ir->increment); - abort(); - } - - if ((ir->cmp < ir_binop_less) || (ir->cmp > ir_binop_nequal)) { - printf("ir_loop has invalid comparitor %d\n", ir->cmp); - abort(); - } - } else { - if ((ir->from != NULL) || (ir->to != NULL) || (ir->increment != NULL)) { - printf("ir_loop has invalid loop controls:\n" - " counter: %p\n" - " from: %p\n" - " to: %p\n" - " increment: %p\n", - (void *) ir->counter, (void *) ir->from, (void *) ir->to, - (void *) ir->increment); - abort(); - } - } - - return visit_continue; -} - - ir_visitor_status ir_validate::visit_enter(ir_function *ir) { diff --git a/src/glsl/ir_variable_refcount.cpp b/src/glsl/ir_variable_refcount.cpp index 425ed812dc3..923eb1a8274 100644 --- a/src/glsl/ir_variable_refcount.cpp +++ b/src/glsl/ir_variable_refcount.cpp @@ -132,24 +132,3 @@ ir_variable_refcount_visitor::visit_leave(ir_assignment *ir) return visit_continue; } - - -ir_visitor_status -ir_variable_refcount_visitor::visit_leave(ir_loop *ir) -{ - /* If the loop has a counter variable, it is implicitly referenced and - * assigned to. Note that since the LHS of an assignment is counted as a - * reference, we actually have to increment referenced_count by 2 so that - * later code will know that the variable isn't just assigned to. - */ - if (ir->counter != NULL) { - ir_variable_refcount_entry *entry = - this->get_variable_entry(ir->counter); - if (entry) { - entry->referenced_count += 2; - entry->assigned_count++; - } - } - - return visit_continue; -} diff --git a/src/glsl/ir_variable_refcount.h b/src/glsl/ir_variable_refcount.h index 03fa7b5b467..c15e8110d04 100644 --- a/src/glsl/ir_variable_refcount.h +++ b/src/glsl/ir_variable_refcount.h @@ -60,7 +60,6 @@ public: virtual ir_visitor_status visit_enter(ir_function_signature *); virtual ir_visitor_status visit_leave(ir_assignment *); - virtual ir_visitor_status visit_leave(ir_loop *); ir_variable_refcount_entry *get_variable_entry(ir_variable *var); diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h index 3c3719b919e..c7fa7ea07c7 100644 --- a/src/glsl/loop_analysis.h +++ b/src/glsl/loop_analysis.h @@ -44,8 +44,7 @@ analyze_loop_variables(exec_list *instructions); * * (if (expression bool ...) (break)) * - * and fill in the \c ir_loop::from, \c ir_loop::to, and \c ir_loop::counter - * fields of the \c ir_loop. + * and fill in the \c normative_bound field of the \c ir_loop. * * In this process, some conditional break-statements may be eliminated * altogether. For example, if it is provable that one loop exit condition will diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index 0eb103f49b8..a1dc20e7198 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; } diff --git a/src/glsl/lower_bounded_loops.cpp b/src/glsl/lower_bounded_loops.cpp index 10f272f36f8..0cd907d91b2 100644 --- a/src/glsl/lower_bounded_loops.cpp +++ b/src/glsl/lower_bounded_loops.cpp @@ -72,34 +72,34 @@ public: ir_visitor_status lower_bounded_loops_visitor::visit_leave(ir_loop *ir) { - if (ir->counter == NULL) + if (ir->normative_bound < 0) return visit_continue; exec_list new_instructions; ir_factory f(&new_instructions, ralloc_parent(ir)); - /* Before the loop, declare the counter and initialize it to "from". */ - f.emit(ir->counter); - f.emit(assign(ir->counter, ir->from)); + /* Before the loop, declare the counter and initialize it to zero. */ + ir_variable *counter = f.make_temp(glsl_type::uint_type, "counter"); + f.emit(assign(counter, f.constant(0u))); ir->insert_before(&new_instructions); - /* At the top of the loop, compare the counter to "to", and break if the - * comparison succeeds. + /* At the top of the loop, compare the counter to normative_bound, and + * break if the comparison succeeds. */ ir_loop_jump *brk = new(f.mem_ctx) ir_loop_jump(ir_loop_jump::jump_break); - ir_expression_operation cmp = (ir_expression_operation) ir->cmp; - ir->body_instructions.push_head(if_tree(expr(cmp, ir->counter, ir->to), - brk)); + ir_if *if_inst = if_tree(gequal(counter, + f.constant((unsigned) ir->normative_bound)), + brk); + ir->body_instructions.push_head(if_inst); /* At the bottom of the loop, increment the counter. */ - ir->body_instructions.push_tail(assign(ir->counter, - add(ir->counter, ir->increment))); - - /* NULL out the counter, from, to, and increment variables. */ - ir->counter = NULL; - ir->from = NULL; - ir->to = NULL; - ir->increment = NULL; + ir->body_instructions.push_tail(assign(counter, + add(counter, f.constant(1u)))); + + /* Since we've explicitly added instructions to terminate the loop, we no + * longer need it to have a normative bound. + */ + ir->normative_bound = -1; this->progress = true; return visit_continue; diff --git a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test index dc9cf8f1a60..c38ed9e70c6 100755 --- a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test +++ b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test @@ -8,6 +8,6 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) break)))))) EOF diff --git a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected index d4bb6fc0274..b278b1c79c1 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected @@ -1,5 +1,5 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) break)))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test index 9b297daf14e..a4a94e05be5 100755 --- a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test +++ b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test @@ -8,7 +8,7 @@ ((declare (in) float b) (declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.000000))) (break) ()))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected index 3771efc7511..90156be8304 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected @@ -1,7 +1,7 @@ ((declare (in) float b) (declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.0))) (break) ()))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test index 366e23093a7..4475eea0b35 100755 --- a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test +++ b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test @@ -9,7 +9,7 @@ ((declare (in) float b) (declare (out) float a) (declare (out) float c) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.000000))) ((assign (x) (var_ref c) (constant float (1.000000))) break) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected index afae5e7c77b..e31a71257de 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected @@ -1,7 +1,7 @@ ((declare (in) float b) (declare (out) float a) (declare (out) float c) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.0))) ((assign (x) (var_ref c) (constant float (1.000000))) break) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test index 350ad628fb3..cb06cfd6ddd 100755 --- a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test +++ b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test @@ -8,7 +8,7 @@ ((declare (in) float b) (declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.000000))) () (break)))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected index 588a3f66a53..3c216ed6a57 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected @@ -1,7 +1,7 @@ ((declare (in) float b) (declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.0))) () (break)))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test index 72b20720572..0a7a11250f2 100755 --- a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test +++ b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test @@ -9,7 +9,7 @@ ((declare (in) float b) (declare (out) float a) (declare (out) float c) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.000000))) () ((assign (x) (var_ref c) (constant float (1.000000))) break)))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected index da2d1a2c820..45e718ddcd6 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected @@ -1,7 +1,7 @@ ((declare (in) float b) (declare (out) float a) (declare (out) float c) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (if (expression bool > (var_ref b) (constant float (0.0))) () ((assign (x) (var_ref c) (constant float (1.000000))) break)))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test index 711ab87218d..47860630567 100755 --- a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test +++ b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test @@ -12,7 +12,7 @@ (declare (in) float cb) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((if (expression bool > (var_ref a) (constant float (0.000000))) ((if (expression bool > (var_ref ba) (constant float (0.000000))) ((if (expression bool > (var_ref bb) (constant float (0.000000))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected index 9adf8655f23..338d751e84d 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected @@ -5,7 +5,7 @@ (signature void (parameters) ((declare (temporary) bool break_flag) (assign (x) (var_ref break_flag) (constant bool (0))) - (loop () () () () + (loop () ((declare (temporary) bool execute_flag) (assign (x) (var_ref execute_flag) (constant bool (1))) (if (expression bool > (var_ref a) (constant float (0.0))) diff --git a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test index a63306931ca..0f84c5d507c 100755 --- a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test +++ b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test @@ -10,7 +10,7 @@ ((declare (in) float aa) (declare (in) float ab) (declare (in) float b) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((if (expression bool > (var_ref aa) (constant float (0.000000))) ((if (expression bool > (var_ref ab) (constant float (0.000000))) (continue) diff --git a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected index a69e2b791a6..3ce323aead8 100644 --- a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected @@ -3,7 +3,7 @@ (signature void (parameters) ((declare (temporary) bool break_flag) (assign (x) (var_ref break_flag) (constant bool (0))) - (loop () () () () + (loop () ((declare (temporary) bool execute_flag) (assign (x) (var_ref execute_flag) (constant bool (1))) (if (expression bool > (var_ref aa) (constant float (0.0))) diff --git a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test index eeae6fd6f9e..cebdad78d36 100755 --- a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test +++ b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test @@ -19,7 +19,7 @@ ((return)) ())) ()) - (loop () () () () + (loop () ((if (expression bool > (var_ref b) (constant float (0.000000))) ((if (expression bool > (var_ref c) (constant float (0.000000))) (break) (continue))) diff --git a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected index b921d307ff6..e4339b14268 100644 --- a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected @@ -14,7 +14,7 @@ ())) ()) (if (var_ref execute_flag) - ((loop () () () () + ((loop () ((if (expression bool > (var_ref b) (constant float (0.0))) ((if (expression bool > (var_ref c) (constant float (0.0))) () (continue))) diff --git a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test index ceb010c7c65..da1caad064e 100755 --- a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test +++ b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test @@ -8,6 +8,6 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) continue)))))) EOF diff --git a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected index d2a02c6f380..df2b5483d86 100644 --- a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected +++ b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected @@ -1,5 +1,5 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))))))))) diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test index a93167b645c..0b46a795130 100755 --- a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test +++ b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test @@ -8,7 +8,7 @@ ((declare (out) float a) (declare (out) float b) (function sub (signature float (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return (constant float (2.000000))))) (assign (x) (var_ref b) (constant float (3.000000))) diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected index 2cf117a5ee1..a1f3cdee713 100644 --- a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected +++ b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected @@ -1,7 +1,7 @@ ((declare (out) float a) (declare (out) float b) (function sub (signature float (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return (constant float (2.000000))))) (assign (x) (var_ref b) (constant float (3.000000))) diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test index 9ce33f0ac2e..0d73a6603b5 100755 --- a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test +++ b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test @@ -8,7 +8,7 @@ ((declare (out) float a) (declare (out) float b) (function sub (signature float (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return (constant float (2.000000))))) (assign (x) (var_ref b) (constant float (3.000000))) diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected index 0bab8f16f30..52bc99ccb3a 100644 --- a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected +++ b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected @@ -6,7 +6,7 @@ (declare (temporary) float return_value) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (loop () () () () + (loop () ((assign (x) (var_ref a) (constant float (1.000000))) (assign (x) (var_ref return_value) (constant float (2.000000))) (assign (x) (var_ref return_flag) (constant bool (1))) diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test index 06988c29571..8b08c996b97 100755 --- a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test +++ b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test @@ -8,7 +8,7 @@ ((declare (out) float a) (declare (out) float b) (function sub (signature float (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return (constant float (2.000000))))) (assign (x) (var_ref b) (constant float (3.000000))) diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected index 0bab8f16f30..52bc99ccb3a 100644 --- a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected +++ b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected @@ -6,7 +6,7 @@ (declare (temporary) float return_value) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (loop () () () () + (loop () ((assign (x) (var_ref a) (constant float (1.000000))) (assign (x) (var_ref return_value) (constant float (2.000000))) (assign (x) (var_ref return_flag) (constant bool (1))) diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test index 45699a897e4..f5b45bc058f 100755 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test @@ -8,7 +8,7 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) EOF diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected index 0bd8037bf00..ae9359ff273 100644 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected @@ -1,6 +1,6 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test index abfa582c291..2a02101d8ff 100755 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test @@ -8,7 +8,7 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) EOF diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected index 53814eaacad..d6dd1db68b5 100644 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected @@ -3,7 +3,7 @@ (signature void (parameters) ((declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (loop () () () () + (loop () ((assign (x) (var_ref a) (constant float (1.000000))) (assign (x) (var_ref return_flag) (constant bool (1))) break)) diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test index a8c5e379136..4c6f9591222 100755 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test @@ -8,7 +8,7 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop () () () () + ((loop () ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) EOF diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected index 53814eaacad..d6dd1db68b5 100644 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected @@ -3,7 +3,7 @@ (signature void (parameters) ((declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (loop () () () () + (loop () ((assign (x) (var_ref a) (constant float (1.000000))) (assign (x) (var_ref return_flag) (constant bool (1))) break)) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 3e32f6e0eba..70eb9979442 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2181,8 +2181,10 @@ fs_visitor::visit(ir_if *ir) void fs_visitor::visit(ir_loop *ir) { - /* Any bounded loops should have been lowered by lower_bounded_loops(). */ - assert(ir->counter == NULL); + /* Any normative loop bounds should have been lowered by + * lower_bounded_loops(). + */ + assert(ir->normative_bound < 0); if (brw->gen < 6 && dispatch_width == 16) { fail("Can't support (non-uniform) control flow on 16-wide\n"); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index cf62e7ed0b0..d0e378b76ef 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1007,8 +1007,10 @@ vec4_visitor::visit(ir_variable *ir) void vec4_visitor::visit(ir_loop *ir) { - /* Any bounded loops should have been lowered by lower_bounded_loops(). */ - assert(ir->counter == NULL); + /* Any normative loop bounds should have been lowered by + * lower_bounded_loops(). + */ + assert(ir->normative_bound < 0); /* We don't want debugging output to print the whole body of the * loop as the annotation. diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 9fd10d1d91c..583cdef9f26 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -759,8 +759,10 @@ ir_to_mesa_visitor::visit(ir_variable *ir) void ir_to_mesa_visitor::visit(ir_loop *ir) { - /* Any bounded loops should have been lowered by lower_bounded_loops(). */ - assert(ir->counter == NULL); + /* Any normative loop bounds should have been lowered by + * lower_bounded_loops(). + */ + assert(ir->normative_bound < 0); emit(NULL, OPCODE_BGNLOOP); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index f748ed85092..18d2a5b0a41 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1137,8 +1137,10 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) void glsl_to_tgsi_visitor::visit(ir_loop *ir) { - /* Any bounded loops should have been lowered by lower_bounded_loops(). */ - assert(ir->counter == NULL); + /* Any normative loop bounds should have been lowered by + * lower_bounded_loops(). + */ + assert(ir->normative_bound < 0); emit(NULL, TGSI_OPCODE_BGNLOOP);