glsl: Optimize ir_triop_lrp(x, y, a) with a = 0.0f or 1.0f
authorMatt Turner <mattst88@gmail.com>
Sat, 16 Feb 2013 01:51:46 +0000 (17:51 -0800)
committerMatt Turner <mattst88@gmail.com>
Thu, 28 Feb 2013 21:18:59 +0000 (13:18 -0800)
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/opt_algebraic.cpp

index 44a21b6c3355dd5f4817c8c40bed43198edf6532..70e016d22aa4fb9aa39e52b5e1648ef3ebe89bb2 100644 (file)
@@ -415,6 +415,17 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
 
       break;
 
+   case ir_triop_lrp:
+      /* Operands are (x, y, a). */
+      if (is_vec_zero(op_const[2])) {
+         this->progress = true;
+         return swizzle_if_required(ir, ir->operands[0]);
+      } else if (is_vec_one(op_const[2])) {
+         this->progress = true;
+         return swizzle_if_required(ir, ir->operands[1]);
+      }
+      break;
+
    default:
       break;
    }