[Mesa-dev] [PATCH 04/10] glsl: Optimize (A || B) && A == A
thomashelland90 at gmail.com
thomashelland90 at gmail.com
Mon Jul 14 15:22:33 PDT 2014
From: Thomas Helland <thomashelland90 at gmail.com>
And it's cousins
Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
src/glsl/opt_algebraic.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 748fd05..230fb1b 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -559,6 +559,16 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
ir->operands[0]->equals(op_expr[1]->operands[0])) {
/* A && !A == 0 */
return ir_constant::zero(mem_ctx, ir->type);
+ } else if (op_expr[0] && op_expr[0]->operation == ir_binop_logic_or &&
+ (op_expr[0]->operands[0]->equals(ir->operands[1]) ||
+ op_expr[0]->operands[1]->equals(ir->operands[1]))) {
+ /* (A || B) && A == A or (B || A) && A == A */
+ return ir->operands[1];
+ } else if (op_expr[1] && op_expr[1]->operation == ir_binop_logic_or &&
+ (op_expr[1]->operands[0]->equals(ir->operands[0]) ||
+ op_expr[1]->operands[1]->equals(ir->operands[0]))) {
+ /* A && (A || B) == A or A && (B || A) == A */
+ return ir->operands[1];
}
break;
--
2.0.0
More information about the mesa-dev
mailing list