From: Eric Anholt Date: Tue, 6 Apr 2010 18:11:05 +0000 (-0700) Subject: Perform constant folding on array indices. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bae5be356eef9efd893e8937d11ecb1b5f3feee6;p=mesa.git Perform constant folding on array indices. Replaces a constant var deref with a constant value in CorrectParse1.frag. --- diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index b9dee37edfb..006eb5ffcfc 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -88,7 +88,14 @@ ir_constant_folding_visitor::visit(ir_swizzle *ir) void ir_constant_folding_visitor::visit(ir_dereference *ir) { - (void) ir; + if (ir->mode == ir_dereference::ir_reference_array) { + ir_constant *const_val = ir->selector.array_index->constant_expression_value(); + if (const_val) + ir->selector.array_index = const_val; + else + ir->selector.array_index->accept(this); + } + ir->var->accept(this); }