glsl: Optimize triop_csel with all-true or all-false.
authorEric Anholt <eric@anholt.net>
Fri, 1 Nov 2013 19:29:12 +0000 (12:29 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 7 Feb 2014 20:46:48 +0000 (12:46 -0800)
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/opt_algebraic.cpp

index 7863fe8f9cf472a38fe245b62d689e795542610c..1b4d319366ccf68d1681ce782b2fe02ba3281d4b 100644 (file)
@@ -571,6 +571,13 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       }
       break;
 
+   case ir_triop_csel:
+      if (is_vec_one(op_const[0]))
+        return ir->operands[1];
+      if (is_vec_zero(op_const[0]))
+        return ir->operands[2];
+      break;
+
    default:
       break;
    }