From: Volker Reichelt Date: Fri, 10 Dec 2004 17:25:07 +0000 (+0000) Subject: re PR rtl-optimization/16536 (Incorrect __restrict__ optimization in -O2) X-Git-Tag: releases/gcc-3.3.6~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3c123ff95c66abb7c73b60990e9e6bdf5c033ed;p=thirdparty%2Fgcc.git re PR rtl-optimization/16536 (Incorrect __restrict__ optimization in -O2) PR rtl-optimization/16536 Backport from mainline: 2004-06-25 Mark Mitchell * alias.c (get_alias_set): Adjust setting of DECL_POINTER_ALIAS_SET for pointers to aggregates. * gcc.c-torture/execute/restrict-1.c: New test. From-SVN: r91999 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 47caee0b9705..05f9b6cbce5c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-12-10 Volker Reichelt + + PR rtl-optimization/16536 + Backport from mainline: + 2004-06-25 Mark Mitchell + * alias.c (get_alias_set): Adjust setting of + DECL_POINTER_ALIAS_SET for pointers to aggregates. + 2004-12-09 Richard Henderson PR target/17025 diff --git a/gcc/alias.c b/gcc/alias.c index abc98de7557a..75ac89d065b7 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -508,6 +508,8 @@ get_alias_set (t) /* If we haven't computed the actual alias set, do it now. */ if (DECL_POINTER_ALIAS_SET (decl) == -2) { + tree pointed_to_type = TREE_TYPE (TREE_TYPE (decl)); + /* No two restricted pointers can point at the same thing. However, a restricted pointer can point at the same thing as an unrestricted pointer, if that unrestricted pointer @@ -516,11 +518,22 @@ get_alias_set (t) alias set for the type pointed to by the type of the decl. */ HOST_WIDE_INT pointed_to_alias_set - = get_alias_set (TREE_TYPE (TREE_TYPE (decl))); + = get_alias_set (pointed_to_type); if (pointed_to_alias_set == 0) /* It's not legal to make a subset of alias set zero. */ - ; + DECL_POINTER_ALIAS_SET (decl) = 0; + else if (AGGREGATE_TYPE_P (pointed_to_type)) + /* For an aggregate, we must treat the restricted + pointer the same as an ordinary pointer. If we + were to make the type pointed to by the + restricted pointer a subset of the pointed-to + type, then we would believe that other subsets + of the pointed-to type (such as fields of that + type) do not conflict with the type pointed to + by the restricted pointer. */ + DECL_POINTER_ALIAS_SET (decl) + = pointed_to_alias_set; else { DECL_POINTER_ALIAS_SET (decl) = new_alias_set (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9f9958a91afe..f9d369063b21 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-12-10 Volker Reichelt + + PR rtl-optimization/16536 + * gcc.c-torture/execute/restrict-1.c: New test. + 2004-12-09 Nathan Sidwell PR c++/16681