From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113232 invoked by alias); 22 Sep 2015 11:42:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 113220 invoked by uid 89); 22 Sep 2015 11:42:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 22 Sep 2015 11:42:27 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34763) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ZeLxp-0001sc-3I for gcc-patches@gnu.org; Tue, 22 Sep 2015 07:42:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeLxl-0001xI-GW for gcc-patches@gnu.org; Tue, 22 Sep 2015 07:42:24 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:39737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeLxl-0001wM-9Q for gcc-patches@gnu.org; Tue, 22 Sep 2015 07:42:21 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZeLxj-0004IA-Ga from Tom_deVries@mentor.com ; Tue, 22 Sep 2015 04:42:19 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Tue, 22 Sep 2015 12:42:17 +0100 To: "gcc-patches@gnu.org" CC: Richard Biener From: Tom de Vries Subject: [PATCH][PR67671] Handle restrict pointer references as restrict in AA Message-ID: <56013E8C.5060703@mentor.com> Date: Tue, 22 Sep 2015 12:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000005060109060902030602" X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 X-SW-Source: 2015-09/txt/msg01638.txt.bz2 --------------000005060109060902030602 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1266 Hi, Consider this test-case: ... struct ps { int *__restrict__ p; }; f (struct ps &__restrict__ ps1) { *(ps1.p) = 1; } ... Atm (meaning after the fix for PR67666) for this test-case, we register two clique/base annotations, one for the load of pointer ps1.p and one for the store to that pointer: ... void f(ps&) (struct psD.2252 & restrict ps1D.2255) { intD.9 * _3; # VUSE <.MEM_1(D)> # PT = { D.2262 } (nonlocal) _3 = MEM[(struct psD.2252 &)ps1_2(D) clique 1 base 1].pD.2254; # .MEM_4 = VDEF <.MEM_1(D)> MEM[(intD.9 *)_3 clique 1 base 2] = 1; ... If we rewrite the test-case by replacing the struct with its only field, we get: ... f (int *__restrict__ &__restrict__ p) { *p = 1; } ... However, in this case, we register only one clique/base annotation, for the load of pointer p, but not for the store to pointer p: ... void f(int* __restrict__&) (intD.9 * restrict & restrict pD.2255) { intD.9 * _3; # VUSE <.MEM_1(D)> # PT = nonlocal escaped _3 = MEM[(intD.9 * restrict &)p_2(D) clique 1 base 1]; # .MEM_4 = VDEF <.MEM_1(D)> *_3 = 1; ... This patch makes sure we register both clique/base annotations for the the second example. Bootstrapped and reg-tested on x86_64. OK for trunk? Thanks, - Tom --------------000005060109060902030602 Content-Type: text/x-patch; name="0001-Handle-restrict-pointer-references-as-restrict-in-AA.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-Handle-restrict-pointer-references-as-restrict-in-AA.pa"; filename*1="tch" Content-length: 1535 Handle restrict pointer references as restrict in AA 2015-09-22 Tom de Vries PR tree-optimization/67671 * tree-ssa-structalias.c (create_variable_info_for_1): Handle restrict pointer references as restrict. * g++.dg/pr67671.C: New test. --- gcc/testsuite/g++.dg/pr67671.C | 12 ++++++++++++ gcc/tree-ssa-structalias.c | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/g++.dg/pr67671.C diff --git a/gcc/testsuite/g++.dg/pr67671.C b/gcc/testsuite/g++.dg/pr67671.C new file mode 100644 index 0000000..952ea4f --- /dev/null +++ b/gcc/testsuite/g++.dg/pr67671.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-ealias-all" } + +void +f (int *__restrict__ &__restrict__ p) +{ + *p = 1; +} + +// { dg-final { scan-tree-dump-times "clique 1 base 1" 1 "ealias" } } +// { dg-final { scan-tree-dump-times "clique 1 base 2" 1 "ealias" } } +// { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index b5b9d0a..0a8998c 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -5684,6 +5684,9 @@ create_variable_info_for_1 (tree decl, const char *name) vi->fullsize = tree_to_uhwi (declsize); vi->size = vi->fullsize; vi->is_full_var = true; + if (POINTER_TYPE_P (TREE_TYPE (decl)) + && TYPE_RESTRICT (TREE_TYPE (decl))) + vi->only_restrict_pointers = 1; fieldstack.release (); return vi; } -- 1.9.1 --------------000005060109060902030602--