glsl: Optimize lrp(0, y, a) into y * a.
authorMatt Turner <mattst88@gmail.com>
Mon, 24 Feb 2014 23:00:44 +0000 (15:00 -0800)
committerMatt Turner <mattst88@gmail.com>
Fri, 28 Feb 2014 18:36:06 +0000 (10:36 -0800)
Helps two programs in shader-db:

instructions in affected programs:     254 -> 234 (-7.87%)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/opt_algebraic.cpp

index 1b4d319366ccf68d1681ce782b2fe02ba3281d4b..28f95a44c7f25a6b07dc604b2a2ab6d2c460331e 100644 (file)
@@ -568,6 +568,8 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
          return ir->operands[1];
       } else if (ir->operands[0]->equals(ir->operands[1])) {
          return ir->operands[0];
+      } else if (is_vec_zero(op_const[0])) {
+         return mul(ir->operands[1], ir->operands[2]);
       }
       break;