From: Thomas Helland <thomashellan...@gmail.com>

And it's exp2() equivalent.

Signed-off-by: Thomas Helland <thomashellan...@gmail.com>
---
 src/glsl/opt_algebraic.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index e2abf5f..2361d0f 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -470,6 +470,17 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       if (is_vec_negative_one(op_const[1]))
          return neg(ir->operands[0]);
 
+      if (op_expr[0] && op_expr[1]) {
+         /* exp(x) * exp(y) == exp(x+y) */
+         if (op_expr[0]->operation == ir_unop_exp &&
+             op_expr[1]->operation == ir_unop_exp)
+            return exp(add(op_expr[0]->operands[0], op_expr[1]->operands[0]));
+         /* exp2(x) * exp2(y) == exp2(x+y) */
+         if (op_expr[0]->operation == ir_unop_exp2 &&
+             op_expr[1]->operation == ir_unop_exp2)
+            return new (mem_ctx) ir_expression(ir_unop_exp2,
+                   add(op_expr[0]->operands[0], op_expr[1]->operands[0]));
+      }
 
       /* Reassociate multiplication of constants so that we can do
        * constant folding.
-- 
2.0.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to