Mesa (master): glsl: Optimize -(-expr) into expr.

Matt Turner mattst88 at kemper.freedesktop.org
Tue Oct 22 05:54:18 UTC 2013


Module: Mesa
Branch: master
Commit: f1e605f1ada79bb4d57187274096d44e270615a6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1e605f1ada79bb4d57187274096d44e270615a6

Author: Matt Turner <mattst88 at gmail.com>
Date:   Wed Oct 16 16:56:45 2013 -0700

glsl: Optimize -(-expr) into expr.

Reviewed-by: Paul Berry <stereotype441 at gmail.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/glsl/opt_algebraic.cpp |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 9b0596c..37b2f02 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;
 




More information about the mesa-commit mailing list