diff options
author | Eric Anholt <[email protected]> | 2014-01-18 10:47:19 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-02-07 12:46:47 -0800 |
commit | 6d7c123d6ce46e71ef22e431b76e972b9be1a157 (patch) | |
tree | b038ad90bd428635c259faa50d8f38fdf0945fd3 /src/glsl | |
parent | 2c2aa353366c610382273bea10656e6d6960ce3b (diff) |
glsl: Optimize log(exp(x)) and exp(log(x)) into x.
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/opt_algebraic.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 681973dda0e..1e715817f76 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; |