From 4acd6b6566df1d91f06c124ead3b4909b342dd3d Mon Sep 17 00:00:00 2001 From: aoliva Date: Tue, 22 Feb 2005 02:27:37 +0000 Subject: [PATCH] gcc/ChangeLog: PR tree-optimization/19786 * tree-ssa-alias.c (compute_flow_insensitive_aliasing): Add one tag to another's may-alias bitmap when adding to the other's list. gcc/testsuite/ChangeLog: PR tree-optimization/19786 * g++.dg/tree-ssa/pr19786.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95377 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/tree-ssa/pr19786.C | 48 +++++++++++++++++++++++++++++++++ gcc/tree-ssa-alias.c | 1 + 4 files changed, 60 insertions(+) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr19786.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 16cb58b19e5..fa3709688c9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-02-21 Alexandre Oliva + + PR tree-optimization/19786 + * tree-ssa-alias.c (compute_flow_insensitive_aliasing): Add one + tag to another's may-alias bitmap when adding to the other's list. + 2005-02-21 DJ Delorie * tree-ssa-loop-ivopts.c (computation_cost): Start register diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0eae7654672..dd742ed74b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-02-21 Alexandre Oliva + + PR tree-optimization/19786 + * g++.dg/tree-ssa/pr19786.C: New. + 2005-02-21 Tobias Schl"uter * lib/gfortran-dg.exp (gfortran-dg-test): Split long regexps. diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr19786.C b/gcc/testsuite/g++.dg/tree-ssa/pr19786.C new file mode 100644 index 00000000000..faaecdfd971 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr19786.C @@ -0,0 +1,48 @@ +// { dg-do run } +/* { dg-options "-O2" } */ + +// We used to get alias grouping wrong on this one, hoisting accesses +// to the vector's end out of the loop. + +#include +#include + +struct A +{ + double unused; // If I remove it => it works. + std::vector v; + + A() : v(1) {} +}; + +inline // If not inline => it works. +A g() +{ + A r; + r.v.resize(2); + r.v[0] = 1; + + while (!r.v.empty() && r.v.back() == 0) + r.v.pop_back(); + + return r; +} + +A f(const A &a) +{ + if (a.v.empty()) return a; + if (a.v.empty()) return a; + + // A z = g(); return z; // If I return like this => it works. + return g(); +} + +int main() +{ + A a; + A b; + A r = f(a); + assert(r.v.size() != 0); + + return 0; +} diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 3e5f8e3dc5f..bfa1685eb9e 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1116,6 +1116,7 @@ compute_flow_insensitive_aliasing (struct alias_info *ai) /* Since TAG2 does not have any aliases of its own, add TAG2 itself to the alias set of TAG1. */ add_may_alias (tag1, tag2); + SET_BIT (may_aliases1, var_ann (tag2)->uid); } } } -- 2.11.4.GIT