re PR tree-optimization/46467 (gcc.dg/torture/pta-structcopy-1.c FAILs with -fipa...
authorRichard Guenther <rguenther@suse.de>
Mon, 15 Nov 2010 14:15:33 +0000 (14:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 15 Nov 2010 14:15:33 +0000 (14:15 +0000)
2010-11-15  Richard Guenther  <rguenther@suse.de>

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.

From-SVN: r166755

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 613abf2ad98e664768b7c94b9f79dd6131210b5c..ad2aecf622270388fd1242120fb1948e2798b50d 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 8c051b3d958f01b065e63e20bffd734e63b6628e..bad83cd98364cbc71385bbe0e8cee7366bc27476 100644 (file)
@@ -1,3 +1,8 @@
+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
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 45efd55b7555572a5da56541372c2bd6fcaa7eb1..8c9ed6c9438d4efd83c4c66a034d220bd0c667c5 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))