Fold constant expressions in if conditionals.
authorEric Anholt <eric@anholt.net>
Tue, 6 Apr 2010 17:07:20 +0000 (10:07 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 6 Apr 2010 18:42:34 +0000 (11:42 -0700)
Fixes up 3 more expressions in CorrectParse2.frag.

ir_constant_folding.cpp

index 306f211fe563a2bb89e507201991209239c65285..b9dee37edfb71fd8ae4bc0d792ab008258667570 100644 (file)
@@ -127,5 +127,9 @@ ir_constant_folding_visitor::visit(ir_return *ir)
 void
 ir_constant_folding_visitor::visit(ir_if *ir)
 {
-   (void) ir;
+   ir_constant *const_val = ir->condition->constant_expression_value();
+   if (const_val)
+      ir->condition = const_val;
+   else
+      ir->condition->accept(this);
 }