summaryrefslogtreecommitdiffstats
path: root/src/glsl/opt_algebraic.cpp
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2013-10-16 16:56:45 -0700
committerMatt Turner <[email protected]>2013-10-21 22:53:36 -0700
commitf1e605f1ada79bb4d57187274096d44e270615a6 (patch)
tree589eb3f88aa5c577b541df7dd7583fdc5829e344 /src/glsl/opt_algebraic.cpp
parent963df4d37da7a7a1ee02cf26e142386a62a611f8 (diff)
glsl: Optimize -(-expr) into expr.
Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/opt_algebraic.cpp')
-rw-r--r--src/glsl/opt_algebraic.cpp10
1 files changed, 10 insertions, 0 deletions
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;