summaryrefslogtreecommitdiffstats
path: root/ast_function.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-06-04 16:20:35 -0700
committerIan Romanick <[email protected]>2010-06-11 13:51:09 -0700
commitc9cb1032be454ff5fdb802a629565cfaeb2e5d5a (patch)
tree85edb658904555edbfac07c027958f66b498498a /ast_function.cpp
parent989cfc432ee7adef701a87783e0c6b064c1cfaee (diff)
Derefence components of constants smarter
During generation of calls to constructors, derefernce constants by creating new constants instead of creating dereferences.
Diffstat (limited to 'ast_function.cpp')
-rw-r--r--ast_function.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/ast_function.cpp b/ast_function.cpp
index 06498b0e379..fc53d7ac1cb 100644
--- a/ast_function.cpp
+++ b/ast_function.cpp
@@ -188,6 +188,13 @@ dereference_component(ir_rvalue *src, unsigned component)
{
assert(component < src->type->components());
+ /* If the source is a constant, just create a new constant instead of a
+ * dereference of the existing constant.
+ */
+ ir_constant *constant = src->as_constant();
+ if (constant)
+ return new ir_constant(constant, component);
+
if (src->type->is_scalar()) {
return src;
} else if (src->type->is_vector()) {