aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-alias.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-10-03 17:20:16 +0200
committerJan Hubicka <jh@suse.cz>2020-10-03 17:20:16 +0200
commitc34db4b6f8a5d80367c709309f9b00cb32630054 (patch)
tree3979a06e5a7afbd74ad4c70342296efcd71c2029 /gcc/tree-ssa-alias.c
parent8510e3301bd519352fc20876da8994f68a0c7e93 (diff)
downloadgcc-c34db4b6f8a5d80367c709309f9b00cb32630054.zip
gcc-c34db4b6f8a5d80367c709309f9b00cb32630054.tar.gz
gcc-c34db4b6f8a5d80367c709309f9b00cb32630054.tar.bz2
Track access ranges in ipa-modref
this patch implements tracking of access ranges. This is only applied when base pointer is an arugment. Incrementally i will extend it to also track TBAA basetype so we can disambiguate ranges for accesses to same basetype (which makes is quite bit more effective). For this reason i track the access offset separately from parameter offset (the second track combined adjustments to the parameter). This is I think last feature I would like to add to the memory access summary this stage1. Further work will be needed to opitmize the summary and merge adjacent range/make collapsing more intelingent (so we do not lose track that often), but I wanted to keep basic patch simple. According to the cc1plus stats: Alias oracle query stats: refs_may_alias_p: 64108082 disambiguations, 74386675 queries ref_maybe_used_by_call_p: 142319 disambiguations, 65004781 queries call_may_clobber_ref_p: 23587 disambiguations, 29420 queries nonoverlapping_component_refs_p: 0 disambiguations, 38117 queries nonoverlapping_refs_since_match_p: 19489 disambiguations, 55748 must overlaps, 76044 queries aliasing_component_refs_p: 54763 disambiguations, 755876 queries TBAA oracle: 24184658 disambiguations 56823187 queries 16260329 are in alias set 0 10617146 queries asked about the same object 125 queries asked about the same alias set 0 access volatile 3960555 are dependent in the DAG 1800374 are aritificially in conflict with void * Modref stats: modref use: 10656 disambiguations, 47037 queries modref clobber: 1473322 disambiguations, 1961464 queries 5027242 tbaa queries (2.563005 per modref query) 649087 base compares (0.330920 per modref query) PTA query stats: pt_solution_includes: 977385 disambiguations, 13609749 queries pt_solutions_intersect: 1032703 disambiguations, 13187507 queries Which should still compare with https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554930.html there is about 2% more load disambiguations and 3.6% more store that is not great, but the TBAA part helps noticeably more and also this should help with -fno-strict-aliasing. I plan to work on improving param tracking too. Bootstrapped/regtested x86_64-linux with the other changes, OK? 2020-10-02 Jan Hubicka <hubicka@ucw.cz> * ipa-modref-tree.c (test_insert_search_collapse): Update andling of accesses. (test_merge): Likewise. * ipa-modref-tree.h (struct modref_access_node): Add offset, size, max_size, parm_offset and parm_offset_known. (modref_access_node::useful_p): Constify. (modref_access_node::range_info_useful_p): New predicate. (modref_access_node::operator==): New. (struct modref_parm_map): New structure. (modref_tree::merge): Update for racking parameters) * ipa-modref.c (dump_access): Dump new fields. (get_access): Fill in new fields. (merge_call_side_effects): Update handling of parm map. (write_modref_records): Stream new fields. (read_modref_records): Stream new fields. (compute_parm_map): Update for new parm map. (ipa_merge_modref_summary_after_inlining): Update. (modref_propagate_in_scc): Update. * tree-ssa-alias.c (modref_may_conflict): Handle known ranges.
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r--gcc/tree-ssa-alias.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3d3a91c..97dc4ac 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -2505,8 +2505,8 @@ modref_may_conflict (const gimple *stmt,
}
/* TBAA checks did not disambiguate, try to use base pointer, for
- that we however need to have ref->ref. */
- if (ref_node->every_access || !ref->ref)
+ that we however need to have ref->ref or ref->base. */
+ if (ref_node->every_access || (!ref->ref && !ref->base))
return true;
modref_access_node *access_node;
@@ -2520,12 +2520,40 @@ modref_may_conflict (const gimple *stmt,
>= gimple_call_num_args (stmt))
return true;
-
alias_stats.modref_baseptr_tests++;
- if (ptr_deref_may_alias_ref_p_1
- (gimple_call_arg (stmt, access_node->parm_index), ref))
+ tree arg = gimple_call_arg (stmt, access_node->parm_index);
+
+ if (integer_zerop (arg) && flag_delete_null_pointer_checks)
+ continue;
+
+ if (!POINTER_TYPE_P (TREE_TYPE (arg)))
return true;
+
+ /* ao_ref_init_from_ptr_and_range assumes that memory access
+ starts by the pointed to location. If we did not track the
+ offset it is possible that it starts before the actual
+ pointer. */
+ if (!access_node->parm_offset_known)
+ {
+ if (ptr_deref_may_alias_ref_p_1 (arg, ref))
+ return true;
+ }
+ else
+ {
+ ao_ref ref2;
+
+ ao_ref_init_from_ptr_and_range
+ (&ref2, arg, true,
+ access_node->offset
+ + (access_node->parm_offset
+ << LOG2_BITS_PER_UNIT), access_node->size,
+ access_node->max_size);
+ ref2.ref_alias_set = ref_set;
+ ref2.base_alias_set = base_set;
+ if (refs_may_alias_p_1 (&ref2, ref, tbaa_p))
+ return true;
+ }
num_tests++;
}
}