]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
emit-rtl.c (set_mem_attributes_minus_bitpos): Treat complex types as aggregates not...
authorJoseph Myers <joseph@codesourcery.com>
Wed, 14 Feb 2007 23:38:01 +0000 (23:38 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Wed, 14 Feb 2007 23:38:01 +0000 (23:38 +0000)
* emit-rtl.c (set_mem_attributes_minus_bitpos): Treat complex
types as aggregates not scalars.
* function.c (assign_stack_temp_for_type): Likewise.

testsuite:
* gcc.dg/torture/complex-alias-1.c: New test.

From-SVN: r121968

gcc/ChangeLog
gcc/emit-rtl.c
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/complex-alias-1.c [new file with mode: 0644]

index 3570907017363bf4e28be2fad7e2aa5d25039ea6..01528f292426842c72115fa279fe65b04943e5bd 100644 (file)
@@ -1,3 +1,9 @@
+2007-02-14  Joseph Myers  <joseph@codesourcery.com>
+
+       * emit-rtl.c (set_mem_attributes_minus_bitpos): Treat complex
+       types as aggregates not scalars.
+       * function.c (assign_stack_temp_for_type): Likewise.
+
 2007-02-14  Roger Sayle  <roger@eyesopen.com>
            Zdenek Dvorak  <dvorakz@suse.cz>
 
index 1faa57ffedb6e408936fcc5cf6c7435cb0ba82fc..9a5db43bc8efec769e98cf8475189c2db3c18b1e 100644 (file)
@@ -1481,12 +1481,15 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
   alias = get_alias_set (t);
 
   MEM_VOLATILE_P (ref) |= TYPE_VOLATILE (type);
-  MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type);
+  MEM_IN_STRUCT_P (ref)
+    = AGGREGATE_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE;
   MEM_POINTER (ref) = POINTER_TYPE_P (type);
 
   /* If we are making an object of this type, or if this is a DECL, we know
      that it is a scalar if the type is not an aggregate.  */
-  if ((objectp || DECL_P (t)) && ! AGGREGATE_TYPE_P (type))
+  if ((objectp || DECL_P (t))
+      && ! AGGREGATE_TYPE_P (type)
+      && TREE_CODE (type) != COMPLEX_TYPE)
     MEM_SCALAR_P (ref) = 1;
 
   /* We can set the alignment from the type if we are making an object,
index 31958b1cf8bea6b80ad2498fc1a927abac750f51..b667a17756078b2d25d94d10beafe450b4765eae 100644 (file)
@@ -763,7 +763,8 @@ assign_stack_temp_for_type (enum machine_mode mode, HOST_WIDE_INT size,
   if (type != 0)
     {
       MEM_VOLATILE_P (slot) = TYPE_VOLATILE (type);
-      MEM_SET_IN_STRUCT_P (slot, AGGREGATE_TYPE_P (type));
+      MEM_SET_IN_STRUCT_P (slot, (AGGREGATE_TYPE_P (type)
+                                 || TREE_CODE (type) == COMPLEX_TYPE));
     }
   MEM_NOTRAP_P (slot) = 1;
 
index 9858417d131469f4359cdad3ba7affe5697439d9..d452713f1d7e874ea30e7ca9ec65a0cf8e130cd8 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-14  Joseph Myers  <joseph@codesourcery.com>
+
+       * gcc.dg/torture/complex-alias-1.c: New test.
+
 2007-02-14  Zdenek Dvorak  <dvorakz@suse.cz>
 
        * gcc.dg/tree-prof/update-tailcall.c: Use -fdump-tree-tailc
diff --git a/gcc/testsuite/gcc.dg/torture/complex-alias-1.c b/gcc/testsuite/gcc.dg/torture/complex-alias-1.c
new file mode 100644 (file)
index 0000000..6ab4ca0
--- /dev/null
@@ -0,0 +1,29 @@
+/* Accesses to complex numbers were sometimes marked as scalar and
+   sometimes as struct accesses.  */
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+extern void abort (void);
+static double _Complex *fp_cxd(double _Complex *cx) {
+  return cx;
+}
+
+int main( ) {
+  double _Complex cx = 4.0 + 3.0*(__extension__ 1.0iF);
+  double _Complex cx43 = 4.0 + 3.0*(__extension__ 1.0iF);
+  double _Complex cx11 = 1.0 + 1.0*(__extension__ 1.0iF);
+
+  *fp_cxd(&cx) *= cx11;
+  *fp_cxd(&cx) /= cx11;
+
+  double r_cx = __real__(cx);
+  double i_cx = __imag__(cx);
+  double r_cx43 = __real__(cx43);
+  double i_cx43 = __imag__(cx43);
+
+  if( (r_cx == r_cx43) && (i_cx == i_cx43) ) { 
+    return 0;
+  } else {
+    abort ();
+  }
+}