summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2015-03-18 10:39:38 -0700
committerMatt Turner <[email protected]>2015-03-24 14:43:37 -0700
commitb481ebbe399fdc6386fd52f890ba7c310d333ed5 (patch)
treede4c3c61ba726eb2aacc9737bae30488cb1f9d17 /src
parentc8e8f660365515560af029651e593f7ee700401c (diff)
glsl: Recognize sat(add(b2f(a), b2f(b))) as a logical OR.
Transform this into b2f(or(a, b)). Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/opt_algebraic.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 0d1f3fcf52c..98c852ae8ba 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -421,6 +421,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
break;
}
+ case ir_unop_saturate:
+ if (op_expr[0] && op_expr[0]->operation == ir_binop_add) {
+ ir_expression *b2f_0 = op_expr[0]->operands[0]->as_expression();
+ ir_expression *b2f_1 = op_expr[0]->operands[1]->as_expression();
+
+ if (b2f_0 && b2f_0->operation == ir_unop_b2f &&
+ b2f_1 && b2f_1->operation == ir_unop_b2f) {
+ return b2f(logic_or(b2f_0->operands[0], b2f_1->operands[0]));
+ }
+ }
+ break;
+
case ir_binop_add:
if (is_vec_zero(op_const[0]))
return ir->operands[1];