On Mon, Oct 23, 2017 at 1:30 PM, Richard Sandiford <richard.sandif...@linaro.org> wrote: > The repeated checks for MEM_REF made this code hard to convert to > poly_ints as-is. Hopefully the new structure also makes it clearer > at a glance what the two cases are. > > > 2017-10-23 Richard Sandiford <richard.sandif...@linaro.org> > Alan Hayward <alan.hayw...@arm.com> > David Sherwood <david.sherw...@arm.com> > > gcc/ > * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid repeated > checks for MEM_REF. > > Index: gcc/tree-ssa-sccvn.c > =================================================================== > --- gcc/tree-ssa-sccvn.c 2017-10-23 11:47:03.852769480 +0100 > +++ gcc/tree-ssa-sccvn.c 2017-10-23 11:47:44.596155858 +0100 > @@ -2234,6 +2234,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree > || offset % BITS_PER_UNIT != 0 > || ref->size % BITS_PER_UNIT != 0) > return (void *)-1; > + at = offset / BITS_PER_UNIT;
can you move this just > /* Extract a pointer base and an offset for the destination. */ > lhs = gimple_call_arg (def_stmt, 0); > @@ -2301,19 +2302,18 @@ vn_reference_lookup_3 (ao_ref *ref, tree > copy_size = tree_to_uhwi (gimple_call_arg (def_stmt, 2)); > > /* The bases of the destination and the references have to agree. */ here? Ok with that change. Richard. > - if ((TREE_CODE (base) != MEM_REF > - && !DECL_P (base)) > - || (TREE_CODE (base) == MEM_REF > - && (TREE_OPERAND (base, 0) != lhs > - || !tree_fits_uhwi_p (TREE_OPERAND (base, 1)))) > - || (DECL_P (base) > - && (TREE_CODE (lhs) != ADDR_EXPR > - || TREE_OPERAND (lhs, 0) != base))) > + if (TREE_CODE (base) == MEM_REF) > + { > + if (TREE_OPERAND (base, 0) != lhs > + || !tree_fits_uhwi_p (TREE_OPERAND (base, 1))) > + return (void *) -1; > + at += tree_to_uhwi (TREE_OPERAND (base, 1)); > + } > + else if (!DECL_P (base) > + || TREE_CODE (lhs) != ADDR_EXPR > + || TREE_OPERAND (lhs, 0) != base) > return (void *)-1; > > - at = offset / BITS_PER_UNIT; > - if (TREE_CODE (base) == MEM_REF) > - at += tree_to_uhwi (TREE_OPERAND (base, 1)); > /* If the access is completely outside of the memcpy destination > area there is no aliasing. */ > if (lhs_offset >= at + maxsize / BITS_PER_UNIT