On Tue, 26 May 2015, Jan Hubicka wrote: > > On Fri, 22 May 2015, Jan Hubicka wrote: > > > > > > > > > > And no, I'm hesitant to change operand_equal_p too much. It's > > > > very much deep-rooted into GENERIC. > > > > > > OK, as another option, i can bring relevant logic from operand_equal_p > > > to ipa-icf and separate it into the compare_operand class like I did. > > > Use it in ipa-icf-gimple now and we can slowly turn other uses of > > > operand_equal into the compare_operand users in middle end. > > > > > > I agree that operand_equal is bit crazy code and it does not handle quite > > > few > > > things we could do at gimple. I have nothing against going this > > > direction. > > > (after all I do not like touching fold-const much becuase it works on > > > generic, > > > gimple and FE non-generic and it is not well specified what it should do) > > > > Yes, I've played with the idea of a GIMPLE specific operand_equal_p > > multiple times but then the changes required to operand_equal_p were > > small all the times. And having one piece of code that does sth is > > always good ... > > > > We might turn operand_equal_p to a "worker" (template?) that > > Hmm, OK that is precisely what I was shooting for by this patch. I went by > wrapping it to a class with valueize helper. It can be template, too, just it > semed that having the single valueize function lets me do everything I need > without actually needing to duplicate the code. > > I can get around templatizing it. Do you have some outline what interface > would seem more fit>
I was thinking about template <bool with_valueize> int operand_equal_p_1 (const_tree arg0, const_tree arg1, unsigned int flags, tree (*valueize)(tree)) { #define VALUEIZE(op) (with_valueize && valueize) ? valueize (op) : op ... } and extern template <> int operand_equal_p_1<false> (const_tree arg0, const_tree arg1, unsigned int flags, tree (*valueize)(tree)); extern template <> int operand_equal_p_1<true> (const_tree arg0, const_tree arg1, unsigned int flags, tree (*valueize)(tree)); int operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) { return operand_equal_p_1<false> (arg0, arg1, flags, NULL); } we don't want to make 'valueize' a template parameter (that is, we don't want to put operand_equal_p_1 to fold-const.h). Same with an eventual 'gimple_p' template parameter (which eventually could simply be the same as the with_valueize one). I'm playing with the idea to make match-and-simplify similar, providing explicit specializations for "common" valueize callbacks. As it always has a valueize callback I'd do it like template <tree (*fixed_valueize)(tree)> bool gimple_simplify (code_helper *res_code, tree *res_ops, gimple_seq *seq, tree (*valueize)(tree), code_helper code, tree type, tree op0) { #define do_valueize(op) \ fixed_valueize != (void *)-1 \ ? (fixed_valueize ? fixed_valueize (op) : op) \ : (valueize ? valueize (op) : op) ... } Richard. > > operand_equal_p and gimple_operand_equal_p can share (with an extra > > flag whether to turn on GIMPLE stuff and/or valueization). And > > then simply provide explicit instantiations for the original > > operand_equal_p and a new gimple_operand_equal_p. > > > > Of course we'll only know if we like that when seeing a patch that > > does this ;0) > > > > Richard. > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)