glsl: Check for zero vectors in ir_binop_dot
authorMatt Turner <mattst88@gmail.com>
Mon, 4 Jun 2012 20:17:12 +0000 (16:17 -0400)
committerMatt Turner <mattst88@gmail.com>
Tue, 12 Jun 2012 22:51:25 +0000 (18:51 -0400)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/opt_algebraic.cpp

index d39761260502bc3e73f1680f3950d830e65652f0..5a9881dbebe7d118d51d28933bc59cc79dd6c4e8 100644 (file)
@@ -309,6 +309,13 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       }
       break;
 
+   case ir_binop_dot:
+      if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) {
+        this->progress = true;
+        return ir_constant::zero(mem_ctx, ir->type);
+      }
+      break;
+
    case ir_binop_logic_and:
       /* FINISHME: Also simplify (a && a) to (a). */
       if (is_vec_one(op_const[0])) {