diff options
author | Eric Anholt <[email protected]> | 2013-10-31 00:10:32 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2013-11-15 11:33:07 -0800 |
commit | ee2704826264eba22d095c3e1e03a8532b7bd1e6 (patch) | |
tree | 8a4339d22b48aaa614689aead2f2f302d951e58f /src/glsl | |
parent | 8957c6b887ff09f44e7b491e7a0551e94a265b8d (diff) |
glsl: Apply the transformation "(a || a) -> a" in opt_algebraic.
total instructions in shared programs: 1732385 -> 1732373 (-0.00%)
instructions in affected programs: 416 -> 404 (-2.88%)
GAINED: 0
LOST: 0
(That's 4 already-short fragment shaders in dota2)
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/opt_algebraic.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index a07e153ae92..3da27e5d61c 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -388,7 +388,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) 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 +406,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; |