[Mesa-dev] [PATCH 1/3] glsl: Check for zero vectors in ir_binop_dot

Kenneth Graunke kenneth at whitecape.org
Tue Jun 12 17:23:41 CEST 2012


On 06/05/2012 11:52 AM, Matt Turner wrote:
> ---
>  src/glsl/opt_algebraic.cpp |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index cade961..1567ecd 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -305,6 +305,13 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>        }
>        break;
>  
> +   case ir_binop_dot:
> +      if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) {
> +	 this->progress = true;
> +	 return ir_constant::zero(mem_ctx, ir->type);
> +      }
> +      break;
> +
>     case ir_binop_logic_and:
>        /* FINISHME: Also simplify (a && a) to (a). */
>        if (is_vec_one(op_const[0])) {

Nice to see this in place!  Always great to kill stupid operations
before they get split up and explode into more code.

For the series:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list