[Mesa-dev] [PATCH 01/10] glsl: Optimize X - X -> 0
thomashelland90 at gmail.com
thomashelland90 at gmail.com
Mon Jul 14 15:22:30 PDT 2014
From: Thomas Helland <thomashelland90 at gmail.com>
Silly optimization indeed, but who knows.
Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
src/glsl/opt_algebraic.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index ac7514a..c179d53 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -439,6 +439,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
return neg(ir->operands[1]);
if (is_vec_zero(op_const[1]))
return ir->operands[0];
+ /* X - X == 0 */
+ if (ir->operands[0]->equals(ir->operands[1]))
+ return ir_constant::zero(ir, ir->type);
break;
case ir_binop_mul:
--
2.0.0
More information about the mesa-dev
mailing list