summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-07-20 11:43:28 -0700
committerEric Anholt <[email protected]>2010-07-20 12:01:40 -0700
commit14f8e16132409f38656e4874aa53bc471977f9ad (patch)
tree2e74685b576046b778b7d124eb87e1fecc12207e
parent5a2e0b8ce59a3d9f8fa7510546137aff40016c74 (diff)
glsl2: Constant-fold assignment conditions.
-rw-r--r--src/glsl/ir_constant_folding.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp
index 2daa6fde38d..66a92e9f3b6 100644
--- a/src/glsl/ir_constant_folding.cpp
+++ b/src/glsl/ir_constant_folding.cpp
@@ -167,6 +167,19 @@ ir_constant_folding_visitor::visit(ir_assignment *ir)
ir->rhs = const_val;
else
ir->rhs->accept(this);
+
+ if (ir->condition) {
+ /* If the condition is constant, either remove the condition or
+ * remove the never-executed assignment.
+ */
+ const_val = ir->condition->constant_expression_value();
+ if (const_val) {
+ if (const_val->value.b[0])
+ ir->condition = NULL;
+ else
+ ir->remove();
+ }
+ }
}