[Mesa-dev] [PATCH 3/5] glsl: Apply the transformation "(a && a) -> a" in opt_algebraic.

Chris Forbes chrisf at ijw.co.nz
Thu Nov 7 14:12:20 PST 2013


Does this affect anything in shader-db?

On Fri, Nov 8, 2013 at 10:58 AM, Eric Anholt <eric at anholt.net> wrote:
> ---
>  src/glsl/opt_algebraic.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index 3da27e5..ea3c386 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -357,7 +357,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>        break;
>
>     case ir_binop_logic_and:
> -      /* FINISHME: Also simplify (a && a) to (a). */
>        if (is_vec_one(op_const[0])) {
>          return ir->operands[1];
>        } else if (is_vec_one(op_const[1])) {
> @@ -371,6 +370,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>            */
>           return logic_not(logic_or(op_expr[0]->operands[0],
>                                     op_expr[1]->operands[0]));
> +      } else if (ir->operands[0]->equals(ir->operands[1])) {
> +         /* (a && a) == a */
> +         return ir->operands[0];
>        }
>        break;
>
> --
> 1.8.4.rc3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list