glsl: Recognize mul(b2f(a), b2f(b)) as a logical AND.
authorMatt Turner <mattst88@gmail.com>
Wed, 18 Mar 2015 06:28:27 +0000 (23:28 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 24 Mar 2015 21:43:37 +0000 (14:43 -0700)
Transform this into b2f(and(a, b)).

total instructions in shared programs: 6190291 -> 6189225 (-0.02%)
instructions in affected programs:     267247 -> 266181 (-0.40%)
helped:                                866

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

index 69c03ea8be7f237d3d9dae60dd40d7fbc2b392d5..0d1f3fcf52c55e3ae411e7e7a0cb3b8d1b33a0a8 100644 (file)
@@ -518,6 +518,10 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       if (is_vec_negative_one(op_const[1]))
          return neg(ir->operands[0]);
 
+      if (op_expr[0] && op_expr[0]->operation == ir_unop_b2f &&
+          op_expr[1] && op_expr[1]->operation == ir_unop_b2f) {
+         return b2f(logic_and(op_expr[0]->operands[0], op_expr[1]->operands[0]));
+      }
 
       /* Reassociate multiplication of constants so that we can do
        * constant folding.