[Mesa-dev] [PATCH 11/11] glsl: Optimize X / X == 1

thomashelland90 at gmail.com thomashelland90 at gmail.com
Thu Aug 7 13:51:12 PDT 2014


From: Thomas Helland <thomashelland90 at gmail.com>

Shows no changes for shader-db.

Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
 src/glsl/opt_algebraic.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 21bf332..a49752d 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -513,6 +513,8 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       }
       if (is_vec_one(op_const[1]))
 	 return ir->operands[0];
+      if(ir->operands[0]->equals(ir->operands[1]))
+         return new(mem_ctx) ir_constant(1.0f, 1);
       break;
 
    case ir_binop_dot:
-- 
2.0.3



More information about the mesa-dev mailing list