glsl: Optimize -(-expr) into expr.
authorMatt Turner <mattst88@gmail.com>
Wed, 16 Oct 2013 23:56:45 +0000 (16:56 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 22 Oct 2013 05:53:36 +0000 (22:53 -0700)
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glsl/opt_algebraic.cpp

index 9b0596cd71a55aa79d20a61bd01c3f010c90f5b0..37b2f02c6e493d82c07dca86864085e2911e8af8 100644 (file)
@@ -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;