From 1a5d20a4e01472c30e360f94b33373f1ab8e2354 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 14 Jul 2011 14:53:30 +0000 Subject: re PR tree-optimization/49651 (nested lambdas and -O3 produced incorrect integer variable increments) 2011-07-14 Richard Guenther 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 | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr49651.c | 31 +++++++++++++++++++++++++++++++ gcc/tree-ssa-structalias.c | 13 +++++++++++-- 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr49651.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 869214d..07b9252 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2011-07-14 Richard Guenther + PR tree-optimization/49651 + * tree-ssa-structalias.c (get_constraint_for_1): Properly + handle dereferences with subvariables. + +2011-07-14 Richard Guenther + * gimple-fold.c (fold_gimple_assign): Remove operand swapping. (fold_stmt_1): Do it here directly on gimple and as a first thing. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 192c908..32b2a0a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-07-14 Richard Guenther + + PR tree-optimization/49651 + * gcc.dg/torture/pr49651.c: New testcase. + 2011-07-14 Georg-Johann Lay 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 index 0000000..c58fe94 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr49651.c @@ -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; +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 6a9732f..82f39c2 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -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); -- cgit v1.1