This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix target/22103


As an aside, evidence that we've got a phase ordering problem
between dead code elimination, may-alias, and sra+complex.

But the problem here is that sra hadn't been taught that some
complex values can't be initialized one part at a time.  Which
I should have done when introducing that concept.


r~


        PR tree-opt/22103
        * tree-sra.c (generate_copy_inout): Handle SSA_NAME complex
        destinations.

Index: tree-sra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-sra.c,v
retrieving revision 2.62
diff -u -p -d -r2.62 tree-sra.c
--- tree-sra.c	6 Jun 2005 21:14:29 -0000	2.62
+++ tree-sra.c	18 Jun 2005 08:47:23 -0000
@@ -1526,7 +1526,22 @@ generate_copy_inout (struct sra_elt *elt
   struct sra_elt *c;
   tree t;
 
-  if (elt->replacement)
+  if (!copy_out && TREE_CODE (expr) == SSA_NAME
+      && TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
+    {
+      tree r, i;
+
+      c = lookup_element (elt, integer_zero_node, NULL, NO_INSERT);
+      r = c->replacement;
+      c = lookup_element (elt, integer_one_node, NULL, NO_INSERT);
+      i = c->replacement;
+
+      t = build (COMPLEX_EXPR, elt->type, r, i);
+      t = build (MODIFY_EXPR, void_type_node, expr, t);
+      SSA_NAME_DEF_STMT (expr) = t;
+      append_to_statement_list (t, list_p);
+    }
+  else if (elt->replacement)
     {
       if (copy_out)
 	t = build (MODIFY_EXPR, void_type_node, elt->replacement, expr);
Index: testsuite/gcc.c-torture/compile/complex-2.c
===================================================================
RCS file: testsuite/gcc.c-torture/compile/complex-2.c
diff -N testsuite/gcc.c-torture/compile/complex-2.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.c-torture/compile/complex-2.c	18 Jun 2005 08:48:04 -0000
@@ -0,0 +1,16 @@
+/* PR 22103 */
+
+_Complex float f(void);
+void *a;
+
+_Complex float g(void)
+{
+  _Complex float x = f();
+  __imag__ x = 1.0;
+  if (__imag__ x != 1.0)
+    {
+      a = &x;
+    }
+  return x;
+}
+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]