[Mesa-dev] [PATCH 4/6] glsl: Optimize lrp(x, x, coefficient) --> x.

Eric Anholt eric at anholt.net
Sun Jan 19 23:18:36 PST 2014


total instructions in shared programs: 1627754 -> 1624534 (-0.20%)
instructions in affected programs:     45748 -> 42528 (-7.04%)
GAINED:                                3
LOST:                                  0

(serious sam, humus domino demo)
---

Note, Matt has a similar patch specific to i965/fs.  This makes the
change global, though apparently less effectively than i965's did.

 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 918982a..4a96a55 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -508,6 +508,8 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
          return ir->operands[0];
       } else if (is_vec_one(op_const[2])) {
          return ir->operands[1];
+      } else if (ir->operands[0]->equals(ir->operands[1])) {
+         return ir->operands[0];
       }
       break;
 
-- 
1.8.5.2



More information about the mesa-dev mailing list