]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-structalias.c (create_variable_info_for): Remove strange whole-program condi...
authorRichard Guenther <rguenther@suse.de>
Wed, 26 Aug 2009 09:02:01 +0000 (09:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 26 Aug 2009 09:02:01 +0000 (09:02 +0000)
2009-08-26  Richard Guenther  <rguenther@suse.de>

* tree-ssa-structalias.c (create_variable_info_for): Remove
strange whole-program condition, prepare to be called for non-globals.
(intra_create_variable_infos): For restrict qualified DECL_BY_REFERENCE
params build a representative with known type and track its fields.

* gcc.dg/tree-ssa/restrict-4.c: New testcase.

From-SVN: r151117

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/restrict-4.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 6a67828d7ae060e8733d78b74e91d15a15f82f63..85f1015f7b99f40c0a041b97e01773625c1039dc 100644 (file)
@@ -1,3 +1,10 @@
+2009-08-26  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-structalias.c (create_variable_info_for): Remove
+       strange whole-program condition, prepare to be called for non-globals.
+       (intra_create_variable_infos): For restrict qualified DECL_BY_REFERENCE
+       params build a representative with known type and track its fields.
+
 2009-08-26  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/alpha/sync.md: Update comment about unpredictable LL/SC lock
index c2236d54f19cdca5f3ce695a10a0fa943f8bfd3b..e11a926dda955b9afda330d8d6b7ab0d758daaed 100644 (file)
@@ -1,3 +1,7 @@
+2009-08-26  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/restrict-4.c: New testcase.
+
 2009-08-26  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/explicit3.C: New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/restrict-4.c b/gcc/testsuite/gcc.dg/tree-ssa/restrict-4.c
new file mode 100644 (file)
index 0000000..3a36def
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile }  */
+/* { dg-options "-O2 -fdump-tree-lim1-details" } */
+
+struct Foo
+{
+  int n;
+  int * __restrict__ p;
+};
+void bar(struct Foo f, int * __restrict__ q)
+{
+  int i;
+  for (i = 0; i < f.n; ++i)
+    {
+      *q += f.p[i];
+    }
+}
+
+/* { dg-final { scan-tree-dump "Executing store motion" "lim1" } } */
+/* { dg-final { cleanup-tree-dump "lim1" } } */
index 72e10835bb567dde3fdb1370a6c54aafbd392478..a9d31325b5746fb97547f08b3a49a59217e1bc55 100644 (file)
@@ -4548,13 +4548,13 @@ create_variable_info_for (tree decl, const char *name)
          newvi->fullsize = vi->fullsize;
          newvi->may_have_pointers = fo->may_have_pointers;
          insert_into_field_list (vi, newvi);
-         if (newvi->is_global_var
-             && (!flag_whole_program || !in_ipa_mode)
+         if ((newvi->is_global_var || TREE_CODE (decl) == PARM_DECL)
              && newvi->may_have_pointers)
            {
               if (fo->only_restrict_pointers)
                 make_constraint_from_restrict (newvi, "GLOBAL_RESTRICT");
-              make_copy_constraint (newvi, nonlocal_id);
+              if (newvi->is_global_var && !in_ipa_mode)
+                make_copy_constraint (newvi, nonlocal_id);
            }
 
          stats.total_vars++;
@@ -4618,8 +4618,41 @@ intra_create_variable_infos (void)
       if (!could_have_pointers (t))
        continue;
 
+      /* 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)))
+       {
+         struct constraint_expr lhsc, rhsc;
+         varinfo_t vi;
+         tree heapvar = heapvar_lookup (t, 0);
+         if (heapvar == NULL_TREE)
+           {
+             var_ann_t ann;
+             heapvar = create_tmp_var_raw (TREE_TYPE (TREE_TYPE (t)),
+                                           "PARM_NOALIAS");
+             DECL_EXTERNAL (heapvar) = 1;
+             heapvar_insert (t, 0, heapvar);
+             ann = get_var_ann (heapvar);
+             ann->is_heapvar = 1;
+           }
+         if (gimple_referenced_vars (cfun))
+           add_referenced_var (heapvar);
+         lhsc.var = get_vi_for_tree (t)->id;
+         lhsc.type = SCALAR;
+         lhsc.offset = 0;
+         rhsc.var = (vi = get_vi_for_tree (heapvar))->id;
+         rhsc.type = ADDRESSOF;
+         rhsc.offset = 0;
+         process_constraint (new_constraint (lhsc, rhsc));
+         vi->is_restrict_var = 1;
+         continue;
+       }
+
       for (p = get_vi_for_tree (t); p; p = p->next)
-       make_constraint_from (p, nonlocal_id);
+       if (p->may_have_pointers)
+         make_constraint_from (p, nonlocal_id);
       if (POINTER_TYPE_P (TREE_TYPE (t))
          && TYPE_RESTRICT (TREE_TYPE (t)))
        make_constraint_from_restrict (get_vi_for_tree (t), "PARM_RESTRICT");