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]

[PATCH]: Fix PR tree-optimization/22376


There are a lot of times we don't actually need to solve the points-to
graph in order to know the results, because every variable already
points to anything, or nothing had its address taken.

22376 is one of those cases :)

This adds a short test that eliminates the time of var substitution and
solving when it's not going to change the results in a way that matters
to us.

This brings the time from 55 seconds to less than a second for PTA time
in the testcase.

Of course, the compilation time is still dominated by out-of-ssa, etc.

--Dan
2005-07-13  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/22376
	* tree-ssa-structalias.c (build_constraint_graph): We really meant
	special var here.
	(need_to_solve): New function.
	(compute_points_to_sets): Use it.

Index: tree-ssa-structalias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-structalias.c,v
retrieving revision 2.19
diff -u -p -r2.19 tree-ssa-structalias.c
--- tree-ssa-structalias.c	13 Jul 2005 14:30:08 -0000	2.19
+++ tree-ssa-structalias.c	13 Jul 2005 14:49:37 -0000
@@ -985,8 +985,8 @@ build_constraint_graph (void)
 	}
       else if (rhs.type == DEREF)
 	{
-	  /* !ANYTHING = *y */
-	  if (lhs.var > anything_id) 
+	  /* !special var= *y */
+	  if (!(get_varinfo (lhs.var)->is_special_var))
 	    insert_into_complex (rhs.var, c);
 	}
       else if (rhs.type == ADDRESSOF)
@@ -3491,6 +3491,38 @@ init_base_vars (void)
   process_constraint (new_constraint (lhs, rhs));
 }  
 
+/* Return true if we actually need to solve the constraint graph in order to
+   get our points-to sets.  This is false when, for example, no addresses are
+   taken other than special vars, or all points-to sets with members already
+   contain the anything variable.  */
+
+static bool
+need_to_solve (void)
+{
+  int i;
+  varinfo_t v;
+  bool found_address_taken = false;
+  bool found_non_anything = false;
+
+  for (i = 0; VEC_iterate (varinfo_t, varmap, i, v); i++)
+    {
+      if (v->is_special_var)
+	continue;
+
+      if (v->address_taken)
+	found_address_taken = true;
+
+      if (v->solution 
+	  && !bitmap_empty_p (v->solution) 
+	  && !bitmap_bit_p (v->solution, anything_id))
+	found_non_anything = true;
+
+      if (found_address_taken && found_non_anything)
+	return true;
+    }
+
+  return false;
+}
 
 /* Create points-to sets for the current function.  See the comments
    at the start of the file for an algorithmic overview.  */
@@ -3541,19 +3573,22 @@ compute_points_to_sets (struct alias_inf
       fprintf (dump_file, "Points-to analysis\n\nConstraints:\n\n");
       dump_constraints (dump_file);
     }
-
-  if (dump_file)
-    fprintf (dump_file, "\nCollapsing static cycles and doing variable "
-	                "substitution:\n");
-
-  find_and_collapse_graph_cycles (graph, false);
-  perform_var_substitution (graph);
-
-  if (dump_file)
-    fprintf (dump_file, "\nSolving graph:\n");
-
-  solve_graph (graph);
-
+  
+  if (need_to_solve ())
+    {
+      if (dump_file)
+	fprintf (dump_file, "\nCollapsing static cycles and doing variable "
+		 "substitution:\n");
+      
+      find_and_collapse_graph_cycles (graph, false);
+      perform_var_substitution (graph);
+      
+      if (dump_file)
+	fprintf (dump_file, "\nSolving graph:\n");
+      
+      solve_graph (graph);
+    }
+  
   if (dump_file)
     dump_sa_points_to_info (dump_file);
   

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