When an alias-set is an already existing subset there is no need to re-record its children as childs of the parent.
I noticed this when doing 1/2 as trivial opportunity to squeeze back some performance for the non-caching recursion I added. The whole thing is still quadratic in the depth of the structure, of course. Bootstrapped and tested on x86_64-unknown-linux-gnu. Since I'm curious I'll test a variant which checks the children are actually recorded before pushing this ... (OK, maybe I shouldn't do this...) Richard. 2020-01-14 Richard Biener <rguent...@suse.de> * alias.c (record_alias_subset): Avoid redundant work when subset is already recorded. --- gcc/alias.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/alias.c b/gcc/alias.c index 9629b5a9f48..3794f9b6a9e 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -1164,10 +1164,16 @@ record_alias_subset (alias_set_type superset, alias_set_type subset) superset_entry->has_zero_child = 1; else { - subset_entry = get_alias_set_entry (subset); if (!superset_entry->children) superset_entry->children = hash_map<alias_set_hash, int>::create_ggc (64); + + /* Enter the SUBSET itself as a child of the SUPERSET. If it was + already there we're done. */ + if (superset_entry->children->put (subset, 0)) + return; + + subset_entry = get_alias_set_entry (subset); /* If there is an entry for the subset, enter all of its children (if they are not already present) as children of the SUPERSET. */ if (subset_entry) @@ -1185,9 +1191,6 @@ record_alias_subset (alias_set_type superset, alias_set_type subset) superset_entry->children->put ((*iter).first, (*iter).second); } } - - /* Enter the SUBSET itself as a child of the SUPERSET. */ - superset_entry->children->put (subset, 0); } } -- 2.16.4