From: Paul Berry Date: Tue, 8 Jan 2013 02:10:30 +0000 (-0800) Subject: glsl: Fix loop bounds detection. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=09df6bb96d5d7b987de6cd48d87d175e5cd2ccf3;p=mesa.git glsl: Fix loop bounds detection. When analyzing a loop where the loop condition is expressed in the non-standard order (e.g. "4 > i" instead of "i < 4"), we were reversing the condition incorrectly, leading to a loop bound that was off by 1. Fixes piglit tests {vs,fs}-loop-bounds-unrolled.shader_test. Reviewed-by: Kenneth Graunke Reviewed-by: Matt Turner Reviewed-by: Eric Anholt --- diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index 9acbadc50ea..79c820436fd 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -222,10 +222,10 @@ loop_control_visitor::visit_leave(ir_loop *ir) limit = cond->operands[0]->as_constant(); switch (cmp) { - case ir_binop_less: cmp = ir_binop_gequal; break; - case ir_binop_greater: cmp = ir_binop_lequal; break; - case ir_binop_lequal: cmp = ir_binop_greater; break; - case ir_binop_gequal: cmp = ir_binop_less; break; + case ir_binop_less: cmp = ir_binop_greater; break; + case ir_binop_greater: cmp = ir_binop_less; break; + case ir_binop_lequal: cmp = ir_binop_gequal; break; + case ir_binop_gequal: cmp = ir_binop_lequal; break; default: assert(!"Should not get here."); } }