From: Thomas Helland <thomashellan...@gmail.com> Specifically x^-1 = rcp(x) . 0^x = 0 . x^0 = 1
Signed-off-by: Thomas Helland <thomashellan...@gmail.com> --- src/glsl/opt_algebraic.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index fba9de6..1382067 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -662,6 +662,21 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (is_vec_one(op_const[1])) return ir->operands[0]; + /* x^-1 == rcp(x) */ + if (is_vec_negative_one(op_const[1])) + return new(mem_ctx) ir_expression(ir_unop_rcp, + ir->operands[0]->type, + ir->operands[0], + NULL); + + /* 0^x == 0 */ + if (is_vec_zero(op_const[0])) + return ir_constant::zero(ir, ir->type); + + /* x^0 == 1 */ + if (is_vec_zero(op_const[1])) + return new(mem_ctx) ir_constant(1.0f, 1); + /* pow(2,x) == exp2(x) */ if (is_vec_two(op_const[0])) return expr(ir_unop_exp2, ir->operands[1]); -- 2.0.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev