> > So about 8times of aliasing_component_refs hitrate. > > OK, one issue with the patch is that it restores TBAA for the > access which we may _not_ do IIRC.
I can see that with stack sharing we have one memory location that for a while is of type A and later is rewritten by type B, but we already give up on optimizing this because of C++ placement new, right? In what scenarios one can disambiguate by the alias set of the reference type (which we do in all cases) but not by the alias set of base type. The code in cfgexpand does not seem to care about either of those. > > > Bootstrapped/regtested x86_64-linux, OK? > > I'd rather not have that new build_simple_mem_ref_with_type_loc > function - the "simple" MEM_REF was to be a way to replace > a plain old INDIRECT_REF. > > So please instead ... > > > 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->base = build2 (MEM_REF, TREE_TYPE (base), *namep, > build_int_cst (TREE_TYPE (*namep), 0)); > > which preserves TBAA behavior but fixes the 'void' type ref. My undrestanding of MEMREF is that it has two types, one is TREE_TYPE (MEMREF) and its ref type taken from TREE_TYPE of the constant. So we will still be dereferencing void which is odd. If globbing is necessary, perhaps the outer type should be somethig like alias set 0 char pointer (used by some builtins such as copysign) or union of all types of vars that gets into a given partition? Honza