ir_to_mesa: Skip useless comparison instructions.
authorMatt Turner <mattst88@gmail.com>
Fri, 4 Dec 2015 00:41:36 +0000 (16:41 -0800)
committerMatt Turner <mattst88@gmail.com>
Thu, 17 Dec 2015 03:59:05 +0000 (19:59 -0800)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/program/ir_to_mesa.cpp

index a0a42daaac5d9ac8cae844e154a19b3701cba8fd..66dea0bbdc24f7561517f0868093705d90e8c942 100644 (file)
@@ -1113,7 +1113,13 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       if (ir->operands[0]->type->is_vector() ||
          ir->operands[1]->type->is_vector()) {
         src_reg temp = get_temp(glsl_type::vec4_type);
-        emit(ir, OPCODE_SNE, dst_reg(temp), op[0], op[1]);
+         if (ir->operands[0]->type->is_boolean() &&
+             ir->operands[1]->as_constant() &&
+             ir->operands[1]->as_constant()->is_zero()) {
+            temp = op[0];
+         } else {
+            emit(ir, OPCODE_SNE, dst_reg(temp), op[0], op[1]);
+         }
 
         /* After the dot-product, the value will be an integer on the
          * range [0,4].  Zero stays zero, and positive values become 1.0.