[Mesa-dev] [PATCH 03/11] glsl: Optimize !A && A == 0
thomashelland90 at gmail.com
thomashelland90 at gmail.com
Thu Aug 7 13:51:04 PDT 2014
From: Thomas Helland <thomashelland90 at gmail.com>
Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/glsl/opt_algebraic.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 67326c5..cdabdb8 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -551,6 +551,14 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
} else if (ir->operands[0]->equals(ir->operands[1])) {
/* (a && a) == a */
return ir->operands[0];
+ } else if (op_expr[0] && op_expr[0]->operation == ir_unop_logic_not &&
+ ir->operands[1]->equals(op_expr[0]->operands[0])) {
+ /* !A && A == 0 */
+ return ir_constant::zero(mem_ctx, ir->type);
+ } else if (op_expr[1] && op_expr[1]->operation == ir_unop_logic_not &&
+ ir->operands[0]->equals(op_expr[1]->operands[0])) {
+ /* A && !A == 0 */
+ return ir_constant::zero(mem_ctx, ir->type);
}
break;
--
2.0.3
More information about the mesa-dev
mailing list