public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, 2/2] Handle recursive restrict pointer in create_variable_info_for_1
@ 2015-10-26 11:24 Tom de Vries
  2015-10-26 16:27 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2015-10-26 11:24 UTC (permalink / raw)
  To: gcc-patches, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

Hi,

this patch enables recursive restrict handling in 
create_variable_info_for_1.

This allows us to interpret all restricts in a function parameter
"int *restrict *restrict *restrict a".

This patch is the first step towards implementing a generic fix for PR67742.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Thanks,
- Tom

[-- Attachment #2: 0002-Handle-recursive-restrict-pointer-in-create_variable.patch --]
[-- Type: text/x-patch, Size: 2237 bytes --]

Handle recursive restrict pointer in create_variable_info_for_1

2015-10-26  Tom de Vries  <tom@codesourcery.com>

	* tree-ssa-structalias.c (create_variable_info_for_1): Enable recursive
	handling of restrict pointers.
	(make_restrict_var_constraints): Handle restrict vars recursively.

	* gcc.dg/tree-ssa/restrict-7.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c | 12 ++++++++++++
 gcc/tree-ssa-structalias.c                 | 13 +++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c b/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c
new file mode 100644
index 0000000..f7a68c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre1" } */
+
+int
+f (int *__restrict__ *__restrict__ *__restrict__ a, int *b)
+{
+  *b = 1;
+  ***a  = 2;
+  return *b;
+}
+
+/* { dg-final { scan-tree-dump-times "return 1" 1 "fre1" } } */
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 3fdad3a..3839f67 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -5696,7 +5696,7 @@ create_variable_info_for_1 (tree decl, const char *name, bool handle_param)
 	  varinfo_t rvi;
 	  tree heapvar = build_fake_var_decl (TREE_TYPE (decl_type));
 	  DECL_EXTERNAL (heapvar) = 1;
-	  rvi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS", false);
+	  rvi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS", true);
 	  rvi->is_restrict_var = 1;
 	  insert_vi_for_tree (heapvar, rvi);
 	  vi->restrict_pointed_var = rvi->id;
@@ -5867,7 +5867,16 @@ make_restrict_var_constraints (varinfo_t vi)
     if (vi->may_have_pointers)
       {
 	if (vi->only_restrict_pointers)
-	  make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT");
+	  {
+	    varinfo_t rvi = get_varinfo (vi->restrict_pointed_var);
+	    if (rvi != NULL)
+	      {
+		make_constraint_from (vi, rvi->id);
+		make_restrict_var_constraints (rvi);
+	      }
+	    else
+	      make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT");
+	  }
 	else
 	  make_copy_constraint (vi, nonlocal_id);
       }
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, 2/2] Handle recursive restrict pointer in create_variable_info_for_1
  2015-10-26 11:24 [PATCH, 2/2] Handle recursive restrict pointer in create_variable_info_for_1 Tom de Vries
@ 2015-10-26 16:27 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2015-10-26 16:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Biener

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

On 26/10/15 12:23, Tom de Vries wrote:
> Hi,
>
> this patch enables recursive restrict handling in
> create_variable_info_for_1.
>
> This allows us to interpret all restricts in a function parameter
> "int *restrict *restrict *restrict a".
>
> This patch is the first step towards implementing a generic fix for
> PR67742.
>
> Bootstrapped and reg-tested on x86_64.
>

Reposting with restrict_pointed_var as a hash_map rather than a field.

> OK for trunk?
>

Thanks,
- Tom

[-- Attachment #2: 0002-Handle-recursive-restrict-pointer-in-create_variable.patch --]
[-- Type: text/x-patch, Size: 2234 bytes --]

Handle recursive restrict pointer in create_variable_info_for_1

2015-10-26  Tom de Vries  <tom@codesourcery.com>

	* tree-ssa-structalias.c (create_variable_info_for_1): Enable recursive
	handling of restrict pointers.
	(make_restrict_var_constraints): Handle restrict vars recursively.

	* gcc.dg/tree-ssa/restrict-7.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c | 12 ++++++++++++
 gcc/tree-ssa-structalias.c                 | 13 +++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c b/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c
new file mode 100644
index 0000000..f7a68c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre1" } */
+
+int
+f (int *__restrict__ *__restrict__ *__restrict__ a, int *b)
+{
+  *b = 1;
+  ***a  = 2;
+  return *b;
+}
+
+/* { dg-final { scan-tree-dump-times "return 1" 1 "fre1" } } */
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index f1325e0..79e9773 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -5726,7 +5726,7 @@ create_variable_info_for_1 (tree decl, const char *name, bool handle_param)
 	  varinfo_t rvi;
 	  tree heapvar = build_fake_var_decl (TREE_TYPE (decl_type));
 	  DECL_EXTERNAL (heapvar) = 1;
-	  rvi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS", false);
+	  rvi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS", true);
 	  rvi->is_restrict_var = 1;
 	  insert_vi_for_tree (heapvar, rvi);
 	  insert_restrict_pointed_var (vi, rvi);
@@ -5897,7 +5897,16 @@ make_restrict_var_constraints (varinfo_t vi)
     if (vi->may_have_pointers)
       {
 	if (vi->only_restrict_pointers)
-	  make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT");
+	  {
+	    varinfo_t rvi = lookup_restrict_pointed_var (vi);
+	    if (rvi != NULL)
+	      {
+		make_constraint_from (vi, rvi->id);
+		make_restrict_var_constraints (rvi);
+	      }
+	    else
+	      make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT");
+	  }
 	else
 	  make_copy_constraint (vi, nonlocal_id);
       }
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-26 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 11:24 [PATCH, 2/2] Handle recursive restrict pointer in create_variable_info_for_1 Tom de Vries
2015-10-26 16:27 ` Tom de Vries

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).