[Mesa-dev] [PATCH 3/3] glsl: Optimize division by two with a right shift.
Matt Turner
mattst88 at gmail.com
Mon Feb 24 15:00:46 PST 2014
---
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 778638c..50342ac 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -421,6 +421,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
}
if (is_vec_one(op_const[1]))
return ir->operands[0];
+ if (is_vec_two(op_const[1]) && ir->type->is_integer()) {
+ return rshift(ir->operands[0], new(mem_ctx) ir_constant(1));
+ }
break;
case ir_binop_dot:
--
1.8.3.2
More information about the mesa-dev
mailing list