summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2013-10-23 16:42:34 -0700
committerMatt Turner <[email protected]>2013-10-25 10:35:18 -0700
commit64c081e8b788ba87c9edc505127b87c3fba47599 (patch)
tree64a50614b5571c2a78ca5fbb9c697839e2ca6ebf
parent65a600f58a7a35016e32e9774560b71f675566fd (diff)
glsl: Optimize (not A) and (not B) into not (A or B).
No shader-db changes, but seems like a good idea. Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/glsl/opt_algebraic.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 22d2dbfe6e3..1351904488b 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -401,6 +401,15 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
} else if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) {
this->progress = true;
return ir_constant::zero(mem_ctx, ir->type);
+ } else if (op_expr[0] && op_expr[0]->operation == ir_unop_logic_not &&
+ op_expr[1] && op_expr[1]->operation == ir_unop_logic_not) {
+ /* De Morgan's Law:
+ * (not A) and (not B) === not (A or B)
+ */
+ temp = logic_not(logic_or(op_expr[0]->operands[0],
+ op_expr[1]->operands[0]));
+ this->progress = true;
+ return swizzle_if_required(ir, temp);
}
break;