OSDN Git Service

2010-11-15 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 15 Nov 2010 14:15:33 +0000 (14:15 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 15 Nov 2010 14:15:33 +0000 (14:15 +0000)
PR tree-optimization/46467
* tree-ssa-structalias.c (do_structure_copy): Properly treat
variables without subvars.

* gcc.dg/ipa/ipa-pta-16.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166755 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/ipa-pta-16.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 613abf2..ad2aecf 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-15  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46467
+       * tree-ssa-structalias.c (do_structure_copy): Properly treat
+       variables without subvars.
+
 2010-11-15  Hariharan Sandanagobalane  <hariharan@picochip.com>
 
        * config/picochip/picochip.c (file header): Picochip name change.
index 8c051b3..bad83cd 100644 (file)
@@ -1,5 +1,10 @@
 2010-11-15  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/46467
+       * gcc.dg/ipa/ipa-pta-16.c: New testcase.
+
+2010-11-15  Richard Guenther  <rguenther@suse.de>
+
        PR testsuite/46423
        * g++.dg/torture/pr34850.C: Adjust.
 
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-pta-16.c b/gcc/testsuite/gcc.dg/ipa/ipa-pta-16.c
new file mode 100644 (file)
index 0000000..ef41826
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-sra -fipa-pta -fdump-ipa-pta" } */
+
+struct X
+{
+  long l1;
+  struct Y
+    {
+      long l2;
+      int *p;
+    } y;
+};
+int i;
+static int __attribute__((noinline))
+foo (struct X *x)
+{
+  struct Y y = x->y;
+  *y.p = 0;
+  i = 1;
+  return *y.p;
+}
+extern void abort (void);
+int main()
+{
+  struct X x;
+  x.y.p = &i;
+  if (foo(&x) != 1)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { scan-ipa-dump "y.\[0-9\]*\\\+\[0-9\]* = { i }" "pta" } } */
+/* { dg-final { cleanup-ipa-dump "pta" } } */
index 45efd55..8c9ed6c 100644 (file)
@@ -3541,11 +3541,15 @@ do_structure_copy (tree lhsop, tree rhsop)
          lhsv = get_varinfo (lhsp->var);
          rhsv = get_varinfo (rhsp->var);
          if (lhsv->may_have_pointers
-             && ranges_overlap_p (lhsv->offset + rhsoffset, lhsv->size,
-                                  rhsv->offset + lhsoffset, rhsv->size))
+             && (lhsv->is_full_var
+                 || rhsv->is_full_var
+                 || ranges_overlap_p (lhsv->offset + rhsoffset, lhsv->size,
+                                      rhsv->offset + lhsoffset, rhsv->size)))
            process_constraint (new_constraint (*lhsp, *rhsp));
-         if (lhsv->offset + rhsoffset + lhsv->size
-             > rhsv->offset + lhsoffset + rhsv->size)
+         if (!rhsv->is_full_var
+             && (lhsv->is_full_var
+                 || (lhsv->offset + rhsoffset + lhsv->size
+                     > rhsv->offset + lhsoffset + rhsv->size)))
            {
              ++k;
              if (k >= VEC_length (ce_s, rhsc))