On Fri, Oct 30, 2015 at 6:35 AM, Jeff Law <l...@redhat.com> wrote: > On 10/29/2015 01:18 PM, Alan Lawrence wrote: >> >> This patch just teaches DOM that ARRAY_REFs can be equivalent to MEM_REFs >> (with >> pointer type to the array element type). >> >> gcc/ChangeLog: >> >> * tree-ssa-dom.c (dom_normalize_single_rhs): New. >> (dom_normalize_gimple_stmt): New. >> (lookup_avail_expr): Call dom_normalize_gimple_stmt. > > Has this been tested? Do you have tests where it can be shown to make a > difference independent of the changes to tree-sra.c? > > The implementation looks fine, I just want to have some basic tests in the > testsuite that show the benefit of this normalization.
Err, I think the implementation is extremely wasteful ... > Similarly for patch #2. Interestingly enough we had code that made that kind > of transformation during gimplification eons ago. Presumably it was ripped > out at some point because of the differences in aliasing properties. Please have a look at how SCCVN handles variants of memory references. You might even want to re-use it's copy_reference_ops_from_ref implementation (and reference hashing). Note that SCCVN needs to be able to reconstruct a tree expression from its representation (for PRE) which DOM needs not, so DOM might use a simpler form. The basic idea is to accumulate constant offset handled_components into a "offset component". Thus a[2].i -> (&a)->offset(8 + offsetof(i)) MEM_REF[&a, 8].i -> (&a)->offset(8 + offsetof(i)) for DOM you can probably do the copy_reference_ops_from_ref work on-the-fly for hashing and comparing. The main point will be to forgo with the DOM way of hashing/comparing for memory references. Richard. > > > Jeff