[Mesa-dev] [PATCH 05/16] glsl: Change to using switch-case in get_range

Ian Romanick idr at freedesktop.org
Wed Nov 19 10:37:43 PST 2014


On 11/16/2014 05:51 PM, Thomas Helland wrote:
> This will make expansion easier and less cluttered.
> ---
>  src/glsl/opt_minmax.cpp | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
> index 89970d5..111d183 100644
> --- a/src/glsl/opt_minmax.cpp
> +++ b/src/glsl/opt_minmax.cpp
> @@ -268,11 +268,20 @@ static minmax_range
>  get_range(ir_rvalue *rval)
>  {
>     ir_expression *expr = rval->as_expression();
> -   if (expr && (expr->operation == ir_binop_min ||
> -                expr->operation == ir_binop_max)) {
> -      minmax_range r0 = get_range(expr->operands[0]);
> -      minmax_range r1 = get_range(expr->operands[1]);
> -      return combine_range(r0, r1, expr->operation == ir_binop_min);
> +   minmax_range r0;
> +   minmax_range r1;
> +
> +   if(expr) {
        ^
        Missing space

> +      switch(expr->operation) {
               ^
               Missing space

> +      case ir_binop_min:
> +      case ir_binop_max:
> +         r0 = get_range(expr->operands[0]);
> +         r1 = get_range(expr->operands[1]);
> +         return combine_range(r0, r1, expr->operation == ir_binop_min);
> +
> +      default:
> +         break;
> +      }
>     }
>  
>     ir_constant *c = rval->as_constant();
> 



More information about the mesa-dev mailing list