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]

Add early exit to access path oracle


Hi,
this patch adds early exit into nonoverlapping_component_refs_since_match_p
so we do not try to parse the access paths when there is obviously nothing to do.
It also improves statistics byt not accounting the early exit as a querry
and also to account cases we found both paths to be matching (so we have kind
of must alias assuming that bases are the same modulo array refs that I plan
to fix soon too).

Bootstrapped/regtested x86_64-linux, comitted.

The stats now look as follows:

Alias oracle query stats:
  refs_may_alias_p: 4392494 disambiguations, 4762170 queries
  ref_maybe_used_by_call_p: 6790 disambiguations, 4418867 queries
  call_may_clobber_ref_p: 883 disambiguations, 883 queries
  nonoverlapping_component_refs_p: 0 disambiguations, 33 queries
  nonoverlapping_component_refs_since_match_p: 66 disambiguations, 2330 must overlaps, 2586 queries
  aliasing_component_refs_p: 932 disambiguations, 30391 queries
  TBAA oracle: 1860937 disambiguations 3844917 queries
               774883 are in alias set 0
               713704 queries asked about the same object
               0 queries asked about the same alias set
               0 access volatile
               356107 are dependent in the DAG
               139286 are aritificially in conflict with void *

PTA query stats:
  pt_solution_includes: 911807 disambiguations, 1226678 queries
  pt_solutions_intersect: 121134 disambiguations, 551599 queries

So we have relatively little work left for nonoverlapping_component_refs_p
and also nonoverlapping_component_refs_since_match_p has overal 256 querries
it may disambiguate because there are different paths, and it suceeds in 66 of them.

Honza

	* tree-ssa-alias.c (alias_stats): Add
	nonoverlapping_component_refs_since_match_p_must_overlap.
	(dump_alias_stats): Print it.
	(nonoverlapping_component_refs_since_match_p): Add early exit.
	(nonoverlapping_component_refs_p): Do not account early exit.
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c	(revision 273130)
+++ tree-ssa-alias.c	(working copy)
@@ -105,6 +105,7 @@ static struct {
   unsigned HOST_WIDE_INT nonoverlapping_component_refs_p_may_alias;
   unsigned HOST_WIDE_INT nonoverlapping_component_refs_p_no_alias;
   unsigned HOST_WIDE_INT nonoverlapping_component_refs_since_match_p_may_alias;
+  unsigned HOST_WIDE_INT nonoverlapping_component_refs_since_match_p_must_overlap;
   unsigned HOST_WIDE_INT nonoverlapping_component_refs_since_match_p_no_alias;
 } alias_stats;
 
@@ -138,10 +139,13 @@ dump_alias_stats (FILE *s)
 	   + alias_stats.nonoverlapping_component_refs_p_may_alias);
   fprintf (s, "  nonoverlapping_component_refs_since_match_p: "
 	   HOST_WIDE_INT_PRINT_DEC" disambiguations, "
+	   HOST_WIDE_INT_PRINT_DEC" must overlaps, "
 	   HOST_WIDE_INT_PRINT_DEC" queries\n",
 	   alias_stats.nonoverlapping_component_refs_since_match_p_no_alias,
+	   alias_stats.nonoverlapping_component_refs_since_match_p_must_overlap,
 	   alias_stats.nonoverlapping_component_refs_since_match_p_no_alias
-	   + alias_stats.nonoverlapping_component_refs_since_match_p_may_alias);
+	   + alias_stats.nonoverlapping_component_refs_since_match_p_may_alias
+	   + alias_stats.nonoverlapping_component_refs_since_match_p_must_overlap);
   fprintf (s, "  aliasing_component_refs_p: "
 	   HOST_WIDE_INT_PRINT_DEC" disambiguations, "
 	   HOST_WIDE_INT_PRINT_DEC" queries\n",
@@ -1149,6 +1153,17 @@ static int
 nonoverlapping_component_refs_since_match_p (tree match1, tree ref1,
 					     tree match2, tree ref2)
 {
+  /* Early return if there are no references to match, we do not need
+     to walk the access paths.
+
+     Do not consider this as may-alias for stats - it is more useful
+     to have information how many disambiguations happened provided that
+     the query was meaningful.  */
+
+  if (match1 == ref1 || !handled_component_p (ref1)
+      || match2 == ref2 || !handled_component_p (ref2))
+    return -1;
+
   auto_vec<tree, 16> component_refs1;
   auto_vec<tree, 16> component_refs2;
 
@@ -1214,7 +1229,7 @@ nonoverlapping_component_refs_since_matc
 	  if (component_refs1.is_empty ())
 	    {
 	      ++alias_stats
-		.nonoverlapping_component_refs_since_match_p_may_alias;
+		.nonoverlapping_component_refs_since_match_p_must_overlap;
 	      return 0;
 	    }
 	  ref1 = component_refs1.pop ();
@@ -1226,7 +1241,7 @@ nonoverlapping_component_refs_since_matc
 	  if (component_refs2.is_empty ())
 	    {
 	      ++alias_stats
-		.nonoverlapping_component_refs_since_match_p_may_alias;
+		.nonoverlapping_component_refs_since_match_p_must_overlap;
 	      return 0;
 	    }
 	  ref2 = component_refs2.pop ();
@@ -1266,7 +1281,7 @@ nonoverlapping_component_refs_since_matc
 	      || DECL_BIT_FIELD_REPRESENTATIVE (field2) == field1)
 	    {
 	      ++alias_stats
-		.nonoverlapping_component_refs_since_match_p_may_alias;
+		.nonoverlapping_component_refs_since_match_p_must_overlap;
 	      return 0;
 	    }
 	  /* Different fields of the same record type cannot overlap.
@@ -1274,7 +1289,7 @@ nonoverlapping_component_refs_since_matc
 	  if (DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2))
 	    {
 	      ++alias_stats
-		.nonoverlapping_component_refs_since_match_p_may_alias;
+		.nonoverlapping_component_refs_since_match_p_must_overlap;
 	      return 0;
 	    }
 	  ++alias_stats.nonoverlapping_component_refs_since_match_p_no_alias;
@@ -1282,7 +1297,7 @@ nonoverlapping_component_refs_since_matc
 	}
     }
 
-  ++alias_stats.nonoverlapping_component_refs_since_match_p_may_alias;
+  ++alias_stats.nonoverlapping_component_refs_since_match_p_must_overlap;
   return 0;
 }
 
@@ -1309,14 +1324,16 @@ ncr_compar (const void *field1_, const v
 static bool
 nonoverlapping_component_refs_p (const_tree x, const_tree y)
 {
+  /* Early return if we have nothing to do.
+
+     Do not consider this as may-alias for stats - it is more useful
+     to have information how many disambiguations happened provided that
+     the query was meaningful.  */
   if (!flag_strict_aliasing
       || !x || !y
       || !handled_component_p (x)
       || !handled_component_p (y))
-    {
-      ++alias_stats.nonoverlapping_component_refs_p_may_alias;
-      return false;
-    }
+    return false;
 
   auto_vec<const_tree, 16> fieldsx;
   while (handled_component_p (x))


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