https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84362
--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> --- On Tue, 18 Dec 2018, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84362 > > --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > The MEM_REF is in there because we first create a _ZNK3vec4sizeEv.isra.0 clone > which takes unsigned int argument and just passes it through. > So, does LIM need to fold the MEM_EXPRs in a similar way to how PRE folds them > to figure out it is the same thing as v.size? The bug somehow felt off my radar. The issue is (IIRC we have some duplicates here) that LIM uses simple iterative_hash_expr and operand_equal_p to equate refs. IIRC I had (partial) patches somewhere to improve the situation here but I can't find them. It might be possible to simply substitute mem_ref_hasher with expr_hash_elt from tree-ssa-scopedtables.h. Let me explore this.