On Mon, May 18, 2015 at 11:17 AM, Richard Biener <richard.guent...@gmail.com> wrote: > On Thu, May 14, 2015 at 4:28 PM, Jeff Law <l...@redhat.com> wrote: >> On 05/14/2015 08:04 AM, Marc Glisse wrote: >>> >>> On Fri, 1 May 2015, Jeff Law wrote: >>> >>>> Slight refactoring of the condition by using types_match as suggested >>>> by Richi. I also applied the new types_match to 2 other patterns in >>>> match.pd where it seemed clearly appropriate. >>> >>> >>> I would like to propose this small tweak (regtested ok). If we had a >>> different type for trees and types, this would be overloading the >>> function. We already do this in a few places, and I find the resulting >>> shorter code more readable. >>> >>> 2015-05-14 Marc Glisse <marc.gli...@inria.fr> >>> >>> * generic-match-head.c (types_match): Handle non-types. >>> * gimple-match-head.c (types_match): Likewise. >>> * match.pd: Remove unnecessary TREE_TYPE for types_match. >> >> Update the comment for types_match and this is fine. > > No - it breaks genmatch autodetection of what trees escape. It special-cases > TREE_TYPE (). See capture_info::walk_c_expr: > > /* Give up for C exprs mentioning captures not inside TREE_TYPE (). */ > unsigned p_depth = 0; > > so the patch will pessimize GENERIC folding. > > Please do not apply.
Hmm, ok - if the functions are only ever used in if()s then it's ok. You just have to remember to never use them in (with ...) expressions or transform results. Like for example (with { bool overflow_p; wide_int mul = wi::mul (@1, @2, TYPE_SIGN (type), &overflow_p); } is bad because genmatch thinks that @1 and @2 might be used multiple times in the simplification because they "escape". It doesn't have sophisticated enough analysis to see that mul is only used in a following 'if'. I suppose we might want to emit warnings from genmatch.c whenever it has to "give up" for multi-use (thus need to emit save_expr ()) or non-use (need to use omit_one_operand if TREE_SIDE_EFFECTS, but as it doesn't know whether it is used in the result we guard the whole pattern with !TREE_SIDE_EFFECTS). Richard. > Richard. > > >> jeff >>