]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* tree-ssa-structalias.c (intra_create_variable_infos): Treat
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Sep 2011 15:03:56 +0000 (15:03 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Sep 2011 15:03:56 +0000 (15:03 +0000)
TYPE_RESTRICT REFERENCE_TYPE parameters like restricted
DECL_BY_REFERENCE parameters.

* g++.dg/tree-ssa/restrict2.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179166 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/restrict2.C [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 2ad1aeffcce36e9ebdb646dd688cec14c9e8fda3..71251cecb26121642df33ede57ae7bb24f3da6e9 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-ssa-structalias.c (intra_create_variable_infos): Treat
+       TYPE_RESTRICT REFERENCE_TYPE parameters like restricted
+       DECL_BY_REFERENCE parameters.
+
 2011-09-25  Eric Botcazou  <ebotcazou@adacore.com>
 
        * tree-eh.c (cleanup_empty_eh): Allow a call to __builtin_stack_restore
index 00eed090b5bfee5e4d275cbd2b8b14ecc3334df3..fc9624f849d8a8f24ae535c2afc8f7cc117e2fb4 100644 (file)
@@ -1,3 +1,7 @@
+2011-09-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * g++.dg/tree-ssa/restrict2.C: New test.
+
 2011-09-25  Ira Rosen  <ira.rosen@linaro.org>
 
        * lib/target-supports.exp (check_effective_target_vect64): New.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/restrict2.C b/gcc/testsuite/g++.dg/tree-ssa/restrict2.C
new file mode 100644 (file)
index 0000000..35957f5
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-optimized" }
+
+struct S { int *__restrict p; int q; };
+S s;
+
+int
+f1 (S x, S y)
+{
+  x.p[0] = 1;
+  y.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 1" 1 "optimized" } }
+  return x.p[0];
+}
+
+int
+f2 (S x)
+{
+  x.p[0] = 2;
+  s.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 2" 1 "optimized" } }
+  return x.p[0];
+}
+
+int
+f3 (S &__restrict x, S &__restrict y)
+{
+  x.p[0] = 3;
+  y.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 3" 1 "optimized" } }
+  return x.p[0];
+}
+
+int
+f4 (S &x, S &y)
+{
+  x.p[0] = 4;
+  y.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 4" 0 "optimized" } }
+  return x.p[0];
+}
+
+int
+f5 (S *__restrict x, S *__restrict y)
+{
+  x->p[0] = 5;
+  y->p[0] = 0;
+// We might handle this some day
+// { dg-final { scan-tree-dump-times "return 5" 1 "optimized" { xfail *-*-* } } }
+  return x->p[0];
+}
+
+int
+f6 (S *x, S *y)
+{
+  x->p[0] = 6;
+  y->p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 6" 0 "optimized" } }
+  return x->p[0];
+}
+
+// { dg-final { cleanup-tree-dump "optimized" } }
index edfbd649d730d3942c232b622056bcab4b2b8422..b2f068a0ac42bcd6fe32cf231be639e2431feaf9 100644 (file)
@@ -5589,10 +5589,11 @@ intra_create_variable_infos (void)
       varinfo_t p;
 
       /* For restrict qualified pointers to objects passed by
-         reference build a real representative for the pointed-to object.  */
-      if (DECL_BY_REFERENCE (t)
-         && POINTER_TYPE_P (TREE_TYPE (t))
-         && TYPE_RESTRICT (TREE_TYPE (t)))
+         reference build a real representative for the pointed-to object.
+        Treat restrict qualified references the same.  */
+      if (TYPE_RESTRICT (TREE_TYPE (t))
+         && ((DECL_BY_REFERENCE (t) && POINTER_TYPE_P (TREE_TYPE (t)))
+             || TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE))
        {
          struct constraint_expr lhsc, rhsc;
          varinfo_t vi;