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

instructions in affected programs:     96 -> 92 (-4.17%)

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

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