From bae5be356eef9efd893e8937d11ecb1b5f3feee6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 11:11:05 -0700 Subject: [PATCH] Perform constant folding on array indices. Replaces a constant var deref with a constant value in CorrectParse1.frag. --- ir_constant_folding.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); } -- 2.30.2