From: Richard Guenther Date: Tue, 3 Jan 2012 13:54:44 +0000 (+0000) Subject: backport: re PR tree-optimization/49279 (Optimization incorrectly presuming constant... X-Git-Tag: releases/gcc-4.5.4~292 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce1831c16abffc465f4ee9add742222bc782dc4f;p=thirdparty%2Fgcc.git backport: re PR tree-optimization/49279 (Optimization incorrectly presuming constant variable inside loop in g++ 4.5 and 4.6 with -O2 and -O3 for x86_64 targets) 2012-01-03 Richard Guenther Backport from mainline 2011-10-06 Jakub Jelinek PR tree-optimization/49279 * tree-ssa-structalias.c (find_func_aliases): Don't handle CAST_RESTRICT. 2011-10-06 Jakub Jelinek PR tree-optimization/49279 * gcc.c-torture/execute/pr49279.c: New test. From-SVN: r182846 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f7f00b5d8494..d8f3174d587a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2012-01-03 Richard Guenther + + Backport from mainline + 2011-10-06 Jakub Jelinek + + PR tree-optimization/49279 + * tree-ssa-structalias.c (find_func_aliases): Don't handle + CAST_RESTRICT. + 2012-01-03 Richard Guenther Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 25e5c8299ce0..1fedf3408125 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2012-01-03 Richard Guenther + + Backport from mainline + 2011-10-06 Jakub Jelinek + + PR tree-optimization/49279 + * gcc.c-torture/execute/pr49279.c: New test. + 2012-01-03 Richard Guenther Backport from mainline diff --git a/gcc/testsuite/gcc.c-torture/execute/pr49279.c b/gcc/testsuite/gcc.c-torture/execute/pr49279.c new file mode 100644 index 000000000000..7f2c0d22129b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr49279.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/49279 */ +extern void abort (void); + +struct S { int a; int *__restrict p; }; + +__attribute__((noinline, noclone)) +struct S *bar (struct S *p) +{ + struct S *r; + asm volatile ("" : "=r" (r) : "0" (p) : "memory"); + return r; +} + +__attribute__((noinline, noclone)) +int +foo (int *p, int *q) +{ + struct S s, *t; + s.a = 1; + s.p = p; + t = bar (&s); + t->p = q; + s.p[0] = 0; + t->p[0] = 1; + return s.p[0]; +} + +int +main () +{ + int a, b; + if (foo (&a, &b) != 1) + abort (); + return 0; +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 88b23c028e69..b2ba385be0a7 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3968,15 +3968,6 @@ find_func_aliases (gimple origt) && DECL_P (lhsop) && is_global_var (lhsop)) make_escape_constraint (rhsop); - /* If this is a conversion of a non-restrict pointer to a - restrict pointer track it with a new heapvar. */ - else if (gimple_assign_cast_p (t) - && POINTER_TYPE_P (TREE_TYPE (rhsop)) - && POINTER_TYPE_P (TREE_TYPE (lhsop)) - && !TYPE_RESTRICT (TREE_TYPE (rhsop)) - && TYPE_RESTRICT (TREE_TYPE (lhsop))) - make_constraint_from_restrict (get_vi_for_tree (lhsop), - "CAST_RESTRICT"); } /* Handle escapes through return. */ else if (gimple_code (t) == GIMPLE_RETURN