Mesa (master): glsl: Optimize log(exp(x)) and exp(log(x)) into x.
Eric Anholt
anholt at kemper.freedesktop.org
Fri Feb 7 20:49:52 UTC 2014
Module: Mesa
Branch: master
Commit: 6d7c123d6ce46e71ef22e431b76e972b9be1a157
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d7c123d6ce46e71ef22e431b76e972b9be1a157
Author: Eric Anholt <eric at anholt.net>
Date: Sat Jan 18 10:47:19 2014 -0800
glsl: Optimize log(exp(x)) and exp(log(x)) into x.
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/glsl/opt_algebraic.cpp | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 681973d..1e71581 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -245,6 +245,42 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
}
break;
+ case ir_unop_exp:
+ if (op_expr[0] == NULL)
+ break;
+
+ if (op_expr[0]->operation == ir_unop_log) {
+ return op_expr[0]->operands[0];
+ }
+ break;
+
+ case ir_unop_log:
+ if (op_expr[0] == NULL)
+ break;
+
+ if (op_expr[0]->operation == ir_unop_exp) {
+ return op_expr[0]->operands[0];
+ }
+ break;
+
+ case ir_unop_exp2:
+ if (op_expr[0] == NULL)
+ break;
+
+ if (op_expr[0]->operation == ir_unop_log2) {
+ return op_expr[0]->operands[0];
+ }
+ break;
+
+ case ir_unop_log2:
+ if (op_expr[0] == NULL)
+ break;
+
+ if (op_expr[0]->operation == ir_unop_exp2) {
+ return 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