Derefence components of constants smarter
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 4 Jun 2010 23:20:35 +0000 (16:20 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 11 Jun 2010 20:51:09 +0000 (13:51 -0700)
During generation of calls to constructors, derefernce constants by creating
new constants instead of creating dereferences.

ast_function.cpp

index 06498b0e379574df0932dcc9e13c5d54fab15759..fc53d7ac1cbc0ce0899c751e703f5b980a2c452a 100644 (file)
@@ -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()) {