projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5a2e0b8
)
glsl2: Constant-fold assignment conditions.
author
Eric Anholt
<eric@anholt.net>
Tue, 20 Jul 2010 18:43:28 +0000
(11:43 -0700)
committer
Eric Anholt
<eric@anholt.net>
Tue, 20 Jul 2010 19:01:40 +0000
(12:01 -0700)
src/glsl/ir_constant_folding.cpp
patch
|
blob
|
history
diff --git
a/src/glsl/ir_constant_folding.cpp
b/src/glsl/ir_constant_folding.cpp
index 2daa6fde38de91de34be6b72d19d037197da1e36..66a92e9f3b632b72f5953c60ae936ff9b5234d46 100644
(file)
--- 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();
+ }
+ }
}