aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/opt_algebraic.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-11-18 09:21:27 +0100
committermarha <marha@users.sourceforge.net>2013-11-18 09:21:27 +0100
commit7c20de6c7fb53ed404d4df0d975328318810ce01 (patch)
tree8f837042966482fd961444153eabbc46cb9141eb /mesalib/src/glsl/opt_algebraic.cpp
parentaa095d69b3874eb179cb77f033109a7f8f351041 (diff)
downloadvcxsrv-7c20de6c7fb53ed404d4df0d975328318810ce01.tar.gz
vcxsrv-7c20de6c7fb53ed404d4df0d975328318810ce01.tar.bz2
vcxsrv-7c20de6c7fb53ed404d4df0d975328318810ce01.zip
libXext mesa xkeyboard-config pixman 18 nov 2013
xkeyboard-config commit 51ab5c95e48b2a040fc132bb5c1a5e8bbe86c8f4 libXext commit bb24f2970f2e425f4df90c9b73d078ad15a73fbb pixman commit f473fd1e7553a4e92a0d72bea360f05d005c9a88 mesa commit 2cfbf84dadc915b7075a3f1cbb569daf699d5ff0
Diffstat (limited to 'mesalib/src/glsl/opt_algebraic.cpp')
-rw-r--r--mesalib/src/glsl/opt_algebraic.cpp19
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) {