[Mesa-dev] [PATCH] glsl: Fix loop bounds detection.

Matt Turner mattst88 at gmail.com
Mon Jan 7 18:41:41 PST 2013


On Mon, Jan 7, 2013 at 6:23 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> 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.
> ---
>  src/glsl/loop_controls.cpp | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
> index 9acbadc..79c8204 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.");
>             }
>          }
> --
> 1.8.1

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list