From: Matt Turner Date: Wed, 16 Oct 2013 23:56:45 +0000 (-0700) Subject: glsl: Optimize -(-expr) into expr. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f1e605f1ada79bb4d57187274096d44e270615a6;p=mesa.git glsl: Optimize -(-expr) into expr. Reviewed-by: Paul Berry Reviewed-by: Eric Anholt --- diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 9b0596cd71a..37b2f02c6e4 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -228,6 +228,16 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) } break; + case ir_unop_neg: + if (op_expr[0] == NULL) + break; + + if (op_expr[0]->operation == ir_unop_neg) { + this->progress = true; + return swizzle_if_required(ir, op_expr[0]->operands[0]); + } + break; + case ir_unop_logic_not: { enum ir_expression_operation new_op = ir_unop_logic_not;