> And that should be done at RTL creation time instead of > repeatedly over and over. Like with the following. > > Bootstrap / regtest on x86_64-unknown-linux-gnu in progress.
Thanks, for TBAA stats I now get Alias oracle query stats: refs_may_alias_p: 3022975 disambiguations, 3321454 queries ref_maybe_used_by_call_p: 6451 disambiguations, 3048555 queries call_may_clobber_ref_p: 817 disambiguations, 817 queries aliasing_component_ref_p: 187 disambiguations, 16103 queries TBAA oracle: 1452502 disambiguations 2956630 queries 550659 are in alias set 0 576739 queries asked about the same object 0 queries asked about the same alias set 0 access volatile 260391 are dependent in the DAG 116339 are aritificially in conflict with void * So some improvement from original (but less great than with my wrong patch): 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 * Honza > > Richard. > > 2019-05-21 Richard Biener <rguent...@suse.de> > > * alias.c (ao_ref_from_mem): Move stack-slot sharing > rewrite ... > * emit-rtl.c (set_mem_attributes_minus_bitpos): ... here. > > Index: gcc/alias.c > =================================================================== > --- gcc/alias.c (revision 271463) > +++ gcc/alias.c (working copy) > @@ -307,18 +307,6 @@ ao_ref_from_mem (ao_ref *ref, const_rtx > && TREE_CODE (TMR_BASE (base)) == SSA_NAME))) > return false; > > - /* If this is a reference based on a partitioned decl replace the > - base with a MEM_REF of the pointer representative we > - created during stack slot partitioning. */ > - if (VAR_P (base) > - && ! is_global_var (base) > - && cfun->gimple_df->decls_to_pointers != NULL) > - { > - tree *namep = cfun->gimple_df->decls_to_pointers->get (base); > - if (namep) > - ref->base = build_simple_mem_ref (*namep); > - } > - > ref->ref_alias_set = MEM_ALIAS_SET (mem); > > /* If MEM_OFFSET or MEM_SIZE are unknown what we got from MEM_EXPR > Index: gcc/emit-rtl.c > =================================================================== > --- gcc/emit-rtl.c (revision 271463) > +++ gcc/emit-rtl.c (working copy) > @@ -61,6 +61,8 @@ along with GCC; see the file COPYING3. > #include "opts.h" > #include "predict.h" > #include "rtx-vector-builder.h" > +#include "gimple.h" > +#include "gimple-ssa.h" > > struct target_rtl default_target_rtl; > #if SWITCHABLE_TARGET > @@ -2128,6 +2130,26 @@ set_mem_attributes_minus_bitpos (rtx ref > apply_bitpos = bitpos; > } > > + /* If this is a reference based on a partitioned decl replace the > + base with a MEM_REF of the pointer representative we created > + during stack slot partitioning. */ > + if (attrs.expr > + && VAR_P (base) > + && ! is_global_var (base) > + && cfun->gimple_df->decls_to_pointers != NULL) > + { > + tree *namep = cfun->gimple_df->decls_to_pointers->get (base); > + if (namep) > + { > + tree *orig_base = &attrs.expr; > + while (handled_component_p (*orig_base)) > + orig_base = &TREE_OPERAND (*orig_base, 0); > + tree aptrt = reference_alias_ptr_type (*orig_base); > + *orig_base = build2 (MEM_REF, TREE_TYPE (*orig_base), *namep, > + build_int_cst (aptrt, 0)); > + } > + } > + > /* Compute the alignment. */ > unsigned int obj_align; > unsigned HOST_WIDE_INT obj_bitpos;