Do simple constant folding while processing function call parameters
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 10 Jun 2010 00:31:02 +0000 (17:31 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 11 Jun 2010 22:37:34 +0000 (15:37 -0700)
ast_function.cpp

index f0c1f0409a07377dfe6eb4e537619f16fbfb47d9..b0700bed5f9ab006638d7cd41ff6b23890466f3d 100644 (file)
@@ -36,7 +36,11 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters,
 
    foreach_list (n, parameters) {
       ast_node *const ast = exec_node_data(ast_node, n, link);
-      ir_rvalue *const result = ast->hir(instructions, state);
+      ir_rvalue *result = ast->hir(instructions, state);
+
+      ir_constant *const constant = result->constant_expression_value();
+      if (constant != NULL)
+        result = constant;
 
       actual_parameters->push_tail(result);
       count++;