From: Eric Anholt Date: Tue, 20 Jul 2010 18:43:28 +0000 (-0700) Subject: glsl2: Constant-fold assignment conditions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=14f8e16132409f38656e4874aa53bc471977f9ad;p=mesa.git glsl2: Constant-fold assignment conditions. --- 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(); + } + } }