re PR tree-optimization/49651 (nested lambdas and -O3 produced incorrect integer...
authorRichard Guenther <rguenther@suse.de>
Thu, 14 Jul 2011 14:53:30 +0000 (14:53 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 14 Jul 2011 14:53:30 +0000 (14:53 +0000)
2011-07-14  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/49651
* tree-ssa-structalias.c (get_constraint_for_1): Properly
handle dereferences with subvariables.

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

From-SVN: r176274

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

index 869214d5836f48388e5c9ea8f7fb54bc1bf50a9a..07b9252be5da05ac9bd98ab46ff86ba3082519e9 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/49651
+       * tree-ssa-structalias.c (get_constraint_for_1): Properly
+       handle dereferences with subvariables.
+
 2011-07-14  Richard Guenther  <rguenther@suse.de>
 
        * gimple-fold.c (fold_gimple_assign): Remove operand swapping.
index 192c908505be1389dbc9a5303c406d289e632c52..32b2a0aa4a6654b0d5f5239d8dc528d02a3e8413 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/49651
+       * gcc.dg/torture/pr49651.c: New testcase.
+
 2011-07-14  Georg-Johann Lay  <avr@gjlay.de>
        
        PR target/43746
diff --git a/gcc/testsuite/gcc.dg/torture/pr49651.c b/gcc/testsuite/gcc.dg/torture/pr49651.c
new file mode 100644 (file)
index 0000000..c58fe94
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+struct X {
+    int *p;
+    int *q;
+};
+
+void __attribute__((noinline, noclone))
+foo (struct X x) { *x.q = 0; }
+
+volatile int what;
+struct X y;
+
+int main()
+{
+  int i, j;
+  struct X x, *p;
+  x.p = &i;
+  x.q = &j;
+  if (what)
+    p = &y;
+  else
+    p = &x;
+  j = 1;
+  foo (*p);
+  if (j != 0)
+    abort ();
+  return 0;
+}
index 6a9732fa1800160f8add5c59166763302f55a93b..82f39c2fcada3918df400beeac013cec1637a7d3 100644 (file)
@@ -3258,9 +3258,18 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
 
              /* If we are not taking the address then make sure to process
                 all subvariables we might access.  */
+             if (address_p)
+               return;
+
              cs = *VEC_last (ce_s, *results);
-             if (address_p
-                 || cs.type != SCALAR)
+             if (cs.type == DEREF)
+               {
+                 /* For dereferences this means we have to defer it
+                    to solving time.  */
+                 VEC_last (ce_s, *results)->offset = UNKNOWN_OFFSET;
+                 return;
+               }
+             if (cs.type != SCALAR)
                return;
 
              vi = get_varinfo (cs.var);