This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: Fix may_alias slowdown in 23835


> If we'd rather split the lists into two, instead of sorting it so there
> is a split, i'm happy to make that change. :)

And here's a version that does it without the sorting, if you like that
better.

(Still being bootstrapped and regtested).

Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.109
diff -u -p -r2.109 tree-ssa-alias.c
--- tree-ssa-alias.c	28 Jul 2005 16:29:53 -0000	2.109
+++ tree-ssa-alias.c	14 Sep 2005 14:45:08 -0000
@@ -568,7 +568,6 @@ delete_alias_info (struct alias_info *ai
   delete_points_to_sets ();
 }
 
-
 /* Create name tags for all the pointers that have been dereferenced.
    We only create a name tag for a pointer P if P is found to point to
    a set of variables (so that we can alias them to *P) or if it is
@@ -582,7 +581,12 @@ static void
 create_name_tags (void)
 {
   size_t i;
+  VEC (tree, heap) *with_ptvars = NULL;
+  tree ptr;
 
+  /* Collect the list of pointers the loops below are going to want to
+     look at.  These are those pointers with SSA_NAME_POINTER_INFO set
+     and don't point to anything.  */
   for (i = 1; i < num_ssa_names; i++)
     {
       tree ptr = ssa_name (i);
@@ -603,68 +607,70 @@ create_name_tags (void)
 	  continue;
 	}
 
-      if (pi->pt_vars && !bitmap_empty_p (pi->pt_vars))
-	{
-	  size_t j;
-	  tree old_name_tag = pi->name_mem_tag;
+      /* Set pt_anything on the pointers without pt_vars filled in.  */
+      
+      if (pi->pt_vars && !bitmap_empty_p (pi->pt_vars))	
+	VEC_safe_push (tree, heap, with_ptvars, ptr);
+      else
+	set_pt_anything (ptr);
+    }
+  
+  /* If we didn't find any pointers with pt_vars set, we're done.  */
+  if (!with_ptvars)
+    return;
 
-	  /* If PTR points to a set of variables, check if we don't
-	     have another pointer Q with the same points-to set before
-	     creating a tag.  If so, use Q's tag instead of creating a
-	     new one.
-
-	     This is important for not creating unnecessary symbols
-	     and also for copy propagation.  If we ever need to
-	     propagate PTR into Q or vice-versa, we would run into
-	     problems if they both had different name tags because
-	     they would have different SSA version numbers (which
-	     would force us to take the name tags in and out of SSA).  */
-	  for (j = 1; j < i; j++)
+  /* Now go through the pointers with pt_vars, and find a name tag
+     with the same pt_vars as this pointer, or create one if one
+     doesn't exist.  */
+  for (i = 0; VEC_iterate (tree, with_ptvars, i, ptr); i++)
+    {
+      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
+      size_t j;
+      tree ptr2;
+      tree old_name_tag = pi->name_mem_tag;
+      
+      /* If PTR points to a set of variables, check if we don't
+	 have another pointer Q with the same points-to set before
+	 creating a tag.  If so, use Q's tag instead of creating a
+	 new one.
+	 
+	 This is important for not creating unnecessary symbols
+	 and also for copy propagation.  If we ever need to
+	 propagate PTR into Q or vice-versa, we would run into
+	 problems if they both had different name tags because
+	 they would have different SSA version numbers (which
+	 would force us to take the name tags in and out of SSA).  */
+      for (j = 0; j < i && VEC_iterate (tree, with_ptvars, j, ptr2); j++)
+	{
+	  struct ptr_info_def *qi = SSA_NAME_PTR_INFO (ptr2);
+	  
+	  if (bitmap_equal_p (pi->pt_vars, qi->pt_vars))
 	    {
-	      tree q = ssa_name (j);
-	      struct ptr_info_def *qi;
-
-	      if (!q || !POINTER_TYPE_P (TREE_TYPE (q)))
-		continue;
-
-	      qi = SSA_NAME_PTR_INFO (q);
-
-	      if (qi
-		  && qi->pt_vars
-		  && qi->name_mem_tag
-		  && bitmap_equal_p (pi->pt_vars, qi->pt_vars))
-		{
-		  pi->name_mem_tag = qi->name_mem_tag;
-		  break;
-		}
+	      pi->name_mem_tag = qi->name_mem_tag;
+	      break;
 	    }
-
-	  /* If we didn't find a pointer with the same points-to set
-	     as PTR, create a new name tag if needed.  */
-	  if (pi->name_mem_tag == NULL_TREE)
-	    pi->name_mem_tag = get_nmt_for (ptr);
-
-	  /* If the new name tag computed for PTR is different than
-	     the old name tag that it used to have, then the old tag
-	     needs to be removed from the IL, so we mark it for
-	     renaming.  */
-	  if (old_name_tag && old_name_tag != pi->name_mem_tag)
-	    mark_sym_for_renaming (old_name_tag);
-	}
-      else
-	{
-	  /* If the pointer does not point to a known spot, we should
-	     use type tags.  */
-	  set_pt_anything (ptr);
-	  continue;
 	}
-
+      
+      /* If we didn't find a pointer with the same points-to set
+	 as PTR, create a new name tag if needed.  */
+      if (pi->name_mem_tag == NULL_TREE)
+	pi->name_mem_tag = get_nmt_for (ptr);
+      
+      /* If the new name tag computed for PTR is different than
+	 the old name tag that it used to have, then the old tag
+	 needs to be removed from the IL, so we mark it for
+	 renaming.  */
+      if (old_name_tag && old_name_tag != pi->name_mem_tag)
+	mark_sym_for_renaming (old_name_tag);
+      
       TREE_THIS_VOLATILE (pi->name_mem_tag)
-	  |= TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (ptr)));
-
+	|= TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (ptr)));
+      
       /* Mark the new name tag for renaming.  */
       mark_sym_for_renaming (pi->name_mem_tag);
     }
+
+  VEC_free (tree, heap, with_ptvars);
 }
 
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]