re PR tree-optimization/26258 (Wrong alias information for struct addresses in PHIs)
authorRichard Guenther <rguenther@suse.de>
Tue, 14 Feb 2006 09:58:57 +0000 (09:58 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 14 Feb 2006 09:58:57 +0000 (09:58 +0000)
2006-02-14  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/26258
* tree-ssa-structalias.c (find_func_aliases): Handle aggregates
in PHI argument processing.

* gcc.dg/torture/pr26258.c: New testcase.

From-SVN: r110963

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr26258.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index ca77775196a9c9160bc61fd9acb7f0bb2bc111d7..2811d2e9d7104e50bf62a480408aad5f27badf94 100644 (file)
@@ -1,3 +1,9 @@
+2006-02-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/26258
+       * tree-ssa-structalias.c (find_func_aliases): Handle aggregates
+       in PHI argument processing.
+
 2006-02-13  Adam Nemet  <anemet@caviumnetworks.com>
 
        * simplify-rtx.c (simplify_unary_operation_1) <TRUNCATE>: Return
index 9cfac859828d3a15d7ceafb7daa0636492a330a2..daac3ab2eea0d7b063d572ae1f5ba2a21381f38b 100644 (file)
@@ -1,3 +1,8 @@
+2006-02-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/26258
+       * gcc.dg/torture/pr26258.c: New testcase.
+
 2006-02-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/26246
diff --git a/gcc/testsuite/gcc.dg/torture/pr26258.c b/gcc/testsuite/gcc.dg/torture/pr26258.c
new file mode 100644 (file)
index 0000000..e9acd55
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+extern void abort(void);
+
+typedef struct Foo { int a; int b; }  Foo;
+
+Foo foo(Foo first, Foo last, _Bool ret_first)
+{
+  Foo t;
+  Foo *t1 = (ret_first ? &first : &last);
+  first.a = 2;
+  last.b = 3;
+  t.a = t1->a;
+  t.b = t1->b;
+  t.a += first.a;
+  t.b += last.b;
+  return t;
+}
+
+int main()
+{
+  Foo first = (Foo){1, 2};
+  Foo last = (Foo){3, 4};
+  Foo ret = foo(first, last, 0);
+  if (ret.b != 6)
+    abort ();
+  return 0;
+}
index fbe9ddfaf26fc86a6261500916c0720241b2d161..2ddbe0f7ff7ada39794202c0fb8a1fa1e12d55ad 100644 (file)
@@ -3239,7 +3239,33 @@ find_func_aliases (tree origt)
          get_constraint_for (PHI_RESULT (t), &lhsc);
          for (i = 0; i < PHI_NUM_ARGS (t); i++)
            { 
+             tree rhstype;
+             tree strippedrhs = PHI_ARG_DEF (t, i);
+
+             STRIP_NOPS (strippedrhs);
+             rhstype = TREE_TYPE (strippedrhs);
              get_constraint_for (PHI_ARG_DEF (t, i), &rhsc);
+
+             if (TREE_CODE (strippedrhs) == ADDR_EXPR
+                && AGGREGATE_TYPE_P (TREE_TYPE (rhstype))
+                && VEC_length (ce_s, rhsc) == 1)
+               {
+                 struct constraint_expr *origrhs;
+                 varinfo_t origvar;
+                 struct constraint_expr tmp;
+
+                 gcc_assert (VEC_length (ce_s, rhsc) == 1);
+                 origrhs = VEC_last (ce_s, rhsc);
+                 tmp = *origrhs;
+                 VEC_pop (ce_s, rhsc);
+                 origvar = get_varinfo (origrhs->var);
+                 for (; origvar; origvar = origvar->next)
+                   {
+                     tmp.var = origvar->id;
+                     VEC_safe_push (ce_s, heap, rhsc, &tmp);
+                   }
+               }
+
              for (j = 0; VEC_iterate (ce_s, lhsc, j, c); j++)
                {
                  struct constraint_expr *c2;