[Mesa-dev] [PATCH 2/2] glsl: Optimize (not A) and (not B) into not (A or B).
Erik Faye-Lund
kusmabite at gmail.com
Thu Oct 24 10:47:01 CEST 2013
On Thu, Oct 24, 2013 at 2:19 AM, Matt Turner <mattst88 at gmail.com> wrote:
> No shader-db changes, but seems like a good idea.
> ---
> src/glsl/opt_algebraic.cpp | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index 3bf0689..1ce9e2d 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -401,6 +401,15 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
> } else if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) {
> this->progress = true;
> return ir_constant::zero(mem_ctx, ir->type);
> + } else if (op_expr[0] && op_expr[0]->operation == ir_unop_logic_not &&
> + op_expr[1] && op_expr[1]->operation == ir_unop_logic_not) {
> + /* De Morgan's Law:
> + * (not A) and (not B) === not (A or B)
> + */
> + temp = logic_not(logic_or(op_expr[0]->operands[0],
> + op_expr[1]->operands[0]));
> + return swizzle_if_required(ir, temp);
> + this->progress = true;
Same here, returning before updating progress?
More information about the mesa-dev
mailing list