]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-alias.c (tree_pointer_compare): New function.
authorDaniel Berlin <dberlin@dberlin.org>
Fri, 24 Nov 2006 01:26:26 +0000 (01:26 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Fri, 24 Nov 2006 01:26:26 +0000 (01:26 +0000)
2006-11-23  Daniel Berlin  <dberlin@dberlin.org>

* tree-ssa-alias.c (tree_pointer_compare): New function.
(compact_name_tags): New function.
(group_aliases): Call compact_name_tags.

From-SVN: r119142

gcc/ChangeLog
gcc/tree-ssa-alias.c
gcc/tree-ssa-structalias.c

index 0244e455aa35200ced4117561c28e5392c5fd76c..5258b592c47e35873aa402e6ad869a8445e68d0f 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-23  Daniel Berlin  <dberlin@dberlin.org>
+
+       * tree-ssa-alias.c (tree_pointer_compare): New function.
+       (compact_name_tags): New function.
+       (group_aliases): Call compact_name_tags.
+
 2006-11-23  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        * real.h (real_isinteger): Declare.
index 275c2449a0db5f3b37ca243b328351522ec42d11..a12dca28025bbcb903b6ca08efe31070725eb230 100644 (file)
@@ -1436,6 +1436,73 @@ group_aliases_into (tree tag, bitmap tag_aliases, struct alias_info *ai)
   tag_ann->may_aliases = NULL;
 }
 
+/* Simple comparison function for qsort that sorts based on pointer
+   address.  */
+
+static int
+tree_pointer_compare (const void *pa, const void *pb)
+{
+  const tree a = *((const tree *)pa);
+  const tree b = *((const tree *)pb);
+  
+  return b - a;
+}
+
+
+/* Replacing may aliases in name tags during grouping can up with the
+   same SMT multiple times in the may_alias list.  It's quicker to
+   just remove them post-hoc than it is to avoid them during
+   replacement.  Thus, this routine sorts the may-alias list and
+   removes duplicates.  */
+
+static void
+compact_name_tags (void)
+{
+  referenced_var_iterator rvi;
+  tree var;
+
+  FOR_EACH_REFERENCED_VAR (var, rvi)
+    {
+      if (TREE_CODE (var) == NAME_MEMORY_TAG)
+       {
+         VEC(tree, gc) *aliases, *new_aliases;
+         tree alias, last_alias;
+         int i;
+         
+         last_alias = NULL;
+         aliases = var_ann (var)->may_aliases;
+         new_aliases = NULL;
+         
+         if (VEC_length (tree, aliases) > 1)
+           {
+             bool changed = false;
+             qsort (VEC_address (tree, aliases), VEC_length (tree, aliases),
+                    sizeof (tree), tree_pointer_compare);
+             
+             for (i = 0; VEC_iterate (tree, aliases, i, alias); i++)
+               {
+                 if (alias == last_alias)
+                   {
+                     changed = true;
+                     continue;
+                   }
+                 
+                 VEC_safe_push (tree, gc, new_aliases, alias);
+                 last_alias = alias;
+               }
+
+             /* Only replace the array if something has changed.  */
+             if (changed)
+               {
+                 VEC_free (tree, gc, aliases);
+                 var_ann (var)->may_aliases = new_aliases;
+               }
+             else
+               VEC_free (tree, gc, new_aliases);
+           }
+       }
+    }
+}
 
 /* Group may-aliases sets to reduce the number of virtual operands due
    to aliasing.
@@ -1597,6 +1664,8 @@ group_aliases (struct alias_info *ai)
        }
     }
 
+  compact_name_tags ();
+
   if (dump_file)
     fprintf (dump_file,
             "%s: Total number of aliased vops after grouping: %ld%s\n",
index 828481c56802d7b4397a83db53d4527ff0e8a7e9..4354b443cbabd2e9935e128f232a94391034ec4a 100644 (file)
@@ -121,7 +121,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   Direct constraints are ADDRESSOF constraints that require no extra
   processing, such as P = &Q
   Copy constraints are those of the form P = Q.
-  Complex constraints are all the constraints involving dereferences.
+  Complex constraints are all the constraints involving dereferences
+  and offsets (including offsetted copies).
   
   3. All direct constraints of the form P = &Q are processed, such
   that Q is added to Sol(P)