From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37477 invoked by alias); 21 Sep 2015 10:05:14 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 37403 invoked by uid 48); 21 Sep 2015 10:05:09 -0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/67666] New: single restrict pointer in struct looses restrict Date: Mon, 21 Sep 2015 10:05:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg01682.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67666 Bug ID: 67666 Summary: single restrict pointer in struct looses restrict Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider testcase test.c: ... struct ps { int *__restrict__ p; }; void f (struct ps &__restrict__ ps1) { *(ps1.p) = 1; } ... Compile the test-case with g++ -O2, and we get one clique/base annotation at ealias (the one for ps1, not the one for p): ... void f(ps&) (struct psD.2252 & restrict ps1D.2255) { intD.9 * _3; # VUSE <.MEM_1(D)> # PT = nonlocal escaped _3 = MEM[(struct psD.2252 &)ps1_2(D) clique 1 base 1].pD.2254; # .MEM_4 = VDEF <.MEM_1(D)> *_3 = 1; ... After applying the patch: ... --- test7.c.orig 2015-09-21 11:38:30.607225802 +0200 +++ test7.c 2015-09-21 11:29:40.891234983 +0200 @@ -1,6 +1,7 @@ struct ps { int *__restrict__ p; + int a; }; void ... we get both clique/base annotations at ealias: ... void f(ps&) (struct psD.2252 & restrict ps1D.2256) { intD.9 * _3; # VUSE <.MEM_1(D)> # PT = { D.2263 } (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; # VUSE <.MEM_4> ... Using this demonstrator patch, I manage to get both clique/base annotations at ealias, without adding an 'int a' field to the struct: ... diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index b5b9d0a..e99feeb 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -5675,8 +5675,7 @@ create_variable_info_for_1 (tree decl, const char *name) /* If we didn't end up collecting sub-variables create a full variable for the decl. */ - if (fieldstack.length () <= 1 - || fieldstack.length () > MAX_FIELDS_FOR_FIELD_SENSITIVE) + if (fieldstack.length () > MAX_FIELDS_FOR_FIELD_SENSITIVE) { vi = new_var_info (decl, name); vi->offset = 0; ...