From 7c20de6c7fb53ed404d4df0d975328318810ce01 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 18 Nov 2013 09:21:27 +0100 Subject: libXext mesa xkeyboard-config pixman 18 nov 2013 xkeyboard-config commit 51ab5c95e48b2a040fc132bb5c1a5e8bbe86c8f4 libXext commit bb24f2970f2e425f4df90c9b73d078ad15a73fbb pixman commit f473fd1e7553a4e92a0d72bea360f05d005c9a88 mesa commit 2cfbf84dadc915b7075a3f1cbb569daf699d5ff0 --- mesalib/src/glsl/opt_algebraic.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'mesalib/src/glsl/opt_algebraic.cpp') diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp index a07e153ae..05a589989 100644 --- a/mesalib/src/glsl/opt_algebraic.cpp +++ b/mesalib/src/glsl/opt_algebraic.cpp @@ -357,7 +357,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) break; case ir_binop_logic_and: - /* FINISHME: Also simplify (a && a) to (a). */ if (is_vec_one(op_const[0])) { return ir->operands[1]; } else if (is_vec_one(op_const[1])) { @@ -371,11 +370,13 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) */ return logic_not(logic_or(op_expr[0]->operands[0], op_expr[1]->operands[0])); + } else if (ir->operands[0]->equals(ir->operands[1])) { + /* (a && a) == a */ + return ir->operands[0]; } break; case ir_binop_logic_xor: - /* FINISHME: Also simplify (a ^^ a) to (false). */ if (is_vec_zero(op_const[0])) { return ir->operands[1]; } else if (is_vec_zero(op_const[1])) { @@ -384,11 +385,13 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) return logic_not(ir->operands[1]); } else if (is_vec_one(op_const[1])) { return logic_not(ir->operands[0]); + } else if (ir->operands[0]->equals(ir->operands[1])) { + /* (a ^^ a) == false */ + return ir_constant::zero(mem_ctx, ir->type); } break; case ir_binop_logic_or: - /* FINISHME: Also simplify (a || a) to (a). */ if (is_vec_zero(op_const[0])) { return ir->operands[1]; } else if (is_vec_zero(op_const[1])) { @@ -407,6 +410,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) */ return logic_not(logic_and(op_expr[0]->operands[0], op_expr[1]->operands[0])); + } else if (ir->operands[0]->equals(ir->operands[1])) { + /* (a || a) == a */ + return ir->operands[0]; } break; @@ -414,10 +420,11 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp) return op_expr[0]->operands[0]; - /* FINISHME: We should do rcp(rsq(x)) -> sqrt(x) for some - * backends, except that some backends will have done sqrt -> - * rcp(rsq(x)) and we don't want to undo it for them. + /* While ir_to_mesa.cpp will lower sqrt(x) to rcp(rsq(x)), it does so at + * its IR level, so we can always apply this transformation. */ + if (op_expr[0] && op_expr[0]->operation == ir_unop_rsq) + return sqrt(op_expr[0]->operands[0]); /* As far as we know, all backends are OK with rsq. */ if (op_expr[0] && op_expr[0]->operation == ir_unop_sqrt) { -- cgit v1.2.3