* [PATCH][PR67671] Handle restrict pointer references as restrict in AA
@ 2015-09-22 12:17 Tom de Vries
2015-09-22 14:12 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2015-09-22 12:17 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Biener
[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]
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
[-- Attachment #2: 0001-Handle-restrict-pointer-references-as-restrict-in-AA.patch --]
[-- Type: text/x-patch, Size: 1535 bytes --]
Handle restrict pointer references as restrict in AA
2015-09-22 Tom de Vries <tom@codesourcery.com>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][PR67671] Handle restrict pointer references as restrict in AA
2015-09-22 12:17 [PATCH][PR67671] Handle restrict pointer references as restrict in AA Tom de Vries
@ 2015-09-22 14:12 ` Richard Biener
2015-10-23 12:12 ` [PATCH] Remove superfluous code in intra_create_variable_infos Tom de Vries
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2015-09-22 14:12 UTC (permalink / raw)
To: Tom de Vries; +Cc: gcc-patches
On Tue, 22 Sep 2015, Tom de Vries wrote:
> 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?
Ok.
Thanks,
Richard.
> Thanks,
> - Tom
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Remove superfluous code in intra_create_variable_infos
2015-09-22 14:12 ` Richard Biener
@ 2015-10-23 12:12 ` Tom de Vries
2015-10-23 12:51 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2015-10-23 12:12 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2478 bytes --]
[ was: Re: [PATCH][PR67671] Handle restrict pointer references as
restrict in AA ]
On 22/09/15 16:02, Richard Biener wrote:
> On Tue, 22 Sep 2015, Tom de Vries wrote:
>
>> >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?
> Ok.
Hi,
I think that after the committed change for PR67671, we arrive here in
intra_create_variable_infos with p->only_restrict_pointers == 1 and
p->next == 0:
...
if (POINTER_TYPE_P (TREE_TYPE (t))
&& TYPE_RESTRICT (TREE_TYPE (t)))
make_constraint_from_global_restrict (p, "PARM_RESTRICT");
...
In other words, we get the same effect if we enter the else branch:
...
else
{
for (; p; p = vi_next (p))
{
if (p->only_restrict_pointers)
make_constraint_from_global_restrict (p, "PARM_RESTRICT");
else if (p->may_have_pointers)
make_constraint_from (p, nonlocal_id);
}
}
...
So, I think we can remove the if branch. Attached patch implements that.
OK for trunk if bootstrap/reg-test succeeds?
Thanks,
- Tom
[-- Attachment #2: 0001-Remove-superfluous-code-in-intra_create_variable_inf.patch --]
[-- Type: text/x-patch, Size: 1177 bytes --]
Remove superfluous code in intra_create_variable_infos
2015-10-23 Tom de Vries <tom@codesourcery.com>
* tree-ssa-structalias.c (intra_create_variable_infos): Remove
superfluous code.
---
gcc/tree-ssa-structalias.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 66a04b2..19db7f5 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -5885,18 +5885,12 @@ intra_create_variable_infos (struct function *fn)
continue;
}
- if (POINTER_TYPE_P (TREE_TYPE (t))
- && TYPE_RESTRICT (TREE_TYPE (t)))
- make_constraint_from_global_restrict (p, "PARM_RESTRICT");
- else
+ for (; p; p = vi_next (p))
{
- for (; p; p = vi_next (p))
- {
- if (p->only_restrict_pointers)
- make_constraint_from_global_restrict (p, "PARM_RESTRICT");
- else if (p->may_have_pointers)
- make_constraint_from (p, nonlocal_id);
- }
+ if (p->only_restrict_pointers)
+ make_constraint_from_global_restrict (p, "PARM_RESTRICT");
+ else if (p->may_have_pointers)
+ make_constraint_from (p, nonlocal_id);
}
}
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Remove superfluous code in intra_create_variable_infos
2015-10-23 12:12 ` [PATCH] Remove superfluous code in intra_create_variable_infos Tom de Vries
@ 2015-10-23 12:51 ` Richard Biener
0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2015-10-23 12:51 UTC (permalink / raw)
To: Tom de Vries; +Cc: gcc-patches
On Fri, 23 Oct 2015, Tom de Vries wrote:
> [ was: Re: [PATCH][PR67671] Handle restrict pointer references as restrict in
> AA ]
>
> On 22/09/15 16:02, Richard Biener wrote:
> > On Tue, 22 Sep 2015, Tom de Vries wrote:
> >
> > > >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?
> > Ok.
>
> Hi,
>
> I think that after the committed change for PR67671, we arrive here in
> intra_create_variable_infos with p->only_restrict_pointers == 1 and p->next ==
> 0:
> ...
> if (POINTER_TYPE_P (TREE_TYPE (t))
> && TYPE_RESTRICT (TREE_TYPE (t)))
> make_constraint_from_global_restrict (p, "PARM_RESTRICT");
> ...
>
> In other words, we get the same effect if we enter the else branch:
> ...
> else
> {
> for (; p; p = vi_next (p))
> {
> if (p->only_restrict_pointers)
> make_constraint_from_global_restrict (p, "PARM_RESTRICT");
> else if (p->may_have_pointers)
> make_constraint_from (p, nonlocal_id);
> }
> }
> ...
>
> So, I think we can remove the if branch. Attached patch implements that.
>
> OK for trunk if bootstrap/reg-test succeeds?
Ok
Richard.
> Thanks,
> - Tom
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-23 12:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22 12:17 [PATCH][PR67671] Handle restrict pointer references as restrict in AA Tom de Vries
2015-09-22 14:12 ` Richard Biener
2015-10-23 12:12 ` [PATCH] Remove superfluous code in intra_create_variable_infos Tom de Vries
2015-10-23 12:51 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).