From: Thomas Helland <thomashellan...@gmail.com> And the log2() equivalent.
v1 -> v2: Correct trailing whitespace Signed-off-by: Thomas Helland <thomashelland90 at gmail.com> Reviewed-by: Eric Anholt <eric at anholt.net> --- src/glsl/opt_algebraic.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 42a70e3..141b930 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -380,6 +380,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) return expr; } + /* log(x) + log(y) == log(x*y) */ + if (op_expr[0] && op_expr[0]->operation == ir_unop_log && + op_expr[1] && op_expr[1]->operation == ir_unop_log) + return new(mem_ctx) ir_expression( + ir_unop_log, mul(op_expr[0]->operands[0], op_expr[1]->operands[0]) ); + + /* log2(x) + log2(y) == log2(x*y) */ + if (op_expr[0] && op_expr[0]->operation == ir_unop_log2 && + op_expr[1] && op_expr[1]->operation == ir_unop_log2) + return new(mem_ctx) ir_expression( + ir_unop_log2, mul(op_expr[0]->operands[0], op_expr[1]->operands[0]) ); + /* Replace (-x + y) * a + x and commutative variations with lrp(x, y, a). * * (-x + y) * a + x -- 2.0.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev