On Thu, 19 Nov 2020, Jan Hubicka wrote: > Hi, > after fixing few issues I gotto stage where 1.4M icf mismatches are due to > comparing two gimple clobber. The problem is that operand_equal_p match > clobber > > case CONSTRUCTOR: > /* In GIMPLE empty constructors are allowed in initializers of > aggregates. */ > return !CONSTRUCTOR_NELTS (arg0) && !CONSTRUCTOR_NELTS (arg1); > > But this happens too late after comparing semantics of its type (that > are not very relevant for memory store and fails way too often). > > In the context of ipa-icf we do not really need to match RHS of gimple > clobbers: > it is enough to know that the LHS stores can be considered equivalent. > > I this added logic to hash them all the same way and compare using > TREE_CLOBBER_P flag. I see other option in extending operand_equal_p > in fold-const to handle them more generously or making stmt hash and compare > to skip comparing/hashing RHS of gimple_clobber_p. > > I am now down to 1453 opernad_equal_p mismatches so it seems we are getting > into shape. > > Bootstrapped/regtested x86_64, looks reasonable? > Honza > > * ipa-icf-gimple.c (func_checker::hash_operand): Hash gimple clobber. > (func_checker::operand_equal_p): Special case gimple clobber. > diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c > index ffb1baddbdb..69bc9ab5b34 100644 > --- a/gcc/ipa-icf-gimple.c > +++ b/gcc/ipa-icf-gimple.c > @@ -245,6 +245,14 @@ func_checker::hash_operand (const_tree arg, > inchash::hash &hstate, > break; > } > > + /* In gimple all clobbers can be considered equal: while comparaing two > + gimple clobbers we match the left hand memory accesses. */ > + if (TREE_CLOBBER_P (arg)) > + { > + hstate.add_int (0xc10bbe5); > + return; > + } > + > return operand_compare::hash_operand (arg, hstate, flags); > } > > @@ -306,6 +314,10 @@ func_checker::operand_equal_p (const_tree t1, const_tree > t2, > default: > break; > } > + /* In gimple all clobbers can be considered equal. We match the right hand
left hand otherwise yes, I guess this will work for ICF. > + memory accesses. */ > + if (TREE_CLOBBER_P (t1) || TREE_CLOBBER_P (t2)) > + return TREE_CLOBBER_P (t1) == TREE_CLOBBER_P (t2); > > return operand_compare::operand_equal_p (t1, t2, flags); > } > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imend