Hi,
while creating shared stack slots we create a fake void * pointer and
merge the corresponidng points-to sets. Later ao_ref_from_mem constructs
mem_ref to feed alias oracle from. Since pointer is void we then
dereference it and keep with void_type mem_ref that does not make much sense.
It also makes oracle to punt later on
/* If either reference is view-converted, give up now. */
if (same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) != 1
|| same_type_for_tbaa (TREE_TYPE (dbase2), TREE_TYPE (base2)) != 1)
return true;
The patch improves access path disambiguation from:
refs_may_alias_p: 3027850 disambiguations, 3340416 queries
ref_maybe_used_by_call_p: 6451 disambiguations, 3053430 queries
call_may_clobber_ref_p: 817 disambiguations, 817 queries
aliasing_component_ref_p: 151 disambiguations, 12565 queries
TBAA oracle: 1468434 disambiguations 3010778 queries
550723 are in alias set 0
614261 queries asked about the same object
0 queries asked about the same alias set
0 access volatile
260983 are dependent in the DAG
116377 are aritificially in conflict with void *
to:
Alias oracle query stats:
refs_may_alias_p: 3029219 disambiguations, 3341410 queries
ref_maybe_used_by_call_p: 6451 disambiguations, 3054799 queries
call_may_clobber_ref_p: 817 disambiguations, 817 queries
aliasing_component_ref_p: 1286 disambiguations, 18458 queries
TBAA oracle: 1468536 disambiguations 3013214 queries
550743 are in alias set 0
616203 queries asked about the same object
0 queries asked about the same alias set
0 access volatile
261355 are dependent in the DAG
116377 are aritificially in conflict with void *
So about 8times of aliasing_component_refs hitrate.
Bootstrapped/regtested x86_64-linux, OK?
Honza
* alias.c (ao_ref_from_mem): Use build_simple_mem_ref_with_type.
* tree.c (build_simple_mem_ref_with_type_loc): Break out from ...
(build_simple_mem_ref_loc): ... here.
* fold-const.h (build_simple_mem_ref_with_type_loc): Declare.
(build_simple_mem_ref_with_type): New macro.
Index: alias.c
===================================================================
--- alias.c (revision 271379)
+++ alias.c (working copy)
@@ -316,7 +316,8 @@ ao_ref_from_mem (ao_ref *ref, const_rtx
{
tree *namep = cfun->gimple_df->decls_to_pointers->get (base);
if (namep)
- ref->base = build_simple_mem_ref (*namep);
+ ref->base = build_simple_mem_ref_with_type
+ (*namep, build_pointer_type (TREE_TYPE (base)));
}
ref->ref_alias_set = MEM_ALIAS_SET (mem);
Index: fold-const.h
===================================================================
--- fold-const.h (revision 271379)
+++ fold-const.h (working copy)
@@ -120,6 +120,9 @@ extern tree fold_indirect_ref_loc (locat
extern tree build_simple_mem_ref_loc (location_t, tree);
#define build_simple_mem_ref(T)\
build_simple_mem_ref_loc (UNKNOWN_LOCATION, T)
+extern tree build_simple_mem_ref_with_type_loc (location_t, tree, tree);
+#define build_simple_mem_ref_with_type(T, T2)\
+ build_simple_mem_ref_with_type_loc (UNKNOWN_LOCATION, T, T2)
extern poly_offset_int mem_ref_offset (const_tree);
extern tree build_invariant_address (tree, tree, poly_int64);
extern tree constant_boolean_node (bool, tree);
Index: tree.c
===================================================================
--- tree.c (revision 271402)
+++ tree.c (working copy)
@@ -4907,14 +4907,14 @@ build5 (enum tree_code code, tree tt, tr
}
/* Build a simple MEM_REF tree with the sematics of a plain INDIRECT_REF
- on the pointer PTR. */
+ on the pointer PTR casted to TYPE. */
tree
-build_simple_mem_ref_loc (location_t loc, tree ptr)
+build_simple_mem_ref_with_type_loc (location_t loc, tree ptr, tree ptype)
{
poly_int64 offset = 0;
- tree ptype = TREE_TYPE (ptr);
tree tem;
+ gcc_checking_assert (POINTER_TYPE_P (ptype) && ptype != void_type_node);
/* For convenience allow addresses that collapse to a simple base
and offset. */
if (TREE_CODE (ptr) == ADDR_EXPR
@@ -4938,6 +4938,15 @@ build_simple_mem_ref_loc (location_t loc
return tem;
}
+/* Build a simple MEM_REF tree with the sematics of a plain INDIRECT_REF
+ on the pointer PTR. */
+
+tree
+build_simple_mem_ref_loc (location_t loc, tree ptr)
+{
+ return build_simple_mem_ref_with_type_loc (loc, ptr, TREE_TYPE (ptr));
+}
+
/* Return the constant offset of a MEM_REF or TARGET_MEM_REF tree T. */
poly_offset_int