glsl2: Constant-fold assignment conditions.

This commit is contained in:
Eric Anholt
2010-07-20 11:43:28 -07:00
parent 5a2e0b8ce5
commit 14f8e16132

View File

@@ -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();
}
}
}