diff options
author | marha <marha@users.sourceforge.net> | 2013-11-18 09:29:58 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-11-18 09:29:58 +0100 |
commit | 72ba71645132923bb8e0b93f7683aef8bc485aa2 (patch) | |
tree | baeaeff7e7ce5bf65f056625b435b8d55d4a04fa /mesalib/src/glsl/opt_algebraic.cpp | |
parent | 4d64875593956234795d9947ac1d225e5b110f0f (diff) | |
parent | 7c20de6c7fb53ed404d4df0d975328318810ce01 (diff) | |
download | vcxsrv-72ba71645132923bb8e0b93f7683aef8bc485aa2.tar.gz vcxsrv-72ba71645132923bb8e0b93f7683aef8bc485aa2.tar.bz2 vcxsrv-72ba71645132923bb8e0b93f7683aef8bc485aa2.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
libXext mesa xkeyboard-config pixman 18 nov 2013
Conflicts:
libXext/src/eat.h
Diffstat (limited to 'mesalib/src/glsl/opt_algebraic.cpp')
-rw-r--r-- | mesalib/src/glsl/opt_algebraic.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
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) { |