Mesa (glsl2): glsl2: Constant-fold assignment conditions.
Eric Anholt
anholt at kemper.freedesktop.org
Tue Jul 20 19:01:58 UTC 2010
Module: Mesa
Branch: glsl2
Commit: 14f8e16132409f38656e4874aa53bc471977f9ad
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=14f8e16132409f38656e4874aa53bc471977f9ad
Author: Eric Anholt <eric at anholt.net>
Date: Tue Jul 20 11:43:28 2010 -0700
glsl2: Constant-fold assignment conditions.
---
src/glsl/ir_constant_folding.cpp | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp
index 2daa6fd..66a92e9 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();
+ }
+ }
}
More information about the mesa-commit
mailing list