https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106164
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #4) > This is the match.pd code: > (for bitop (bit_and bit_ior) > (for cmp (tcc_comparison) > (for ocmp (tcc_comparison) > (for ncmp (tcc_comparison) > (simplify > (bitop (cmp:c @0 @1) (ocmp @0 @1)) > (with { > #if GIMPLE > location_t loc = UNKNOWN_LOCATION; > #endif > tree t = combine_comparisons (loc, > bitop == BIT_IOR_EXPR > ? TRUTH_ORIF_EXPR : TRUTH_ANDIF_EXPR, > cmp, ocmp, > type, @0, @1); > } > (switch > (if (GENERIC && t) > {t;}) > (if (t && CONSTANT_CLASS_P (t)) > {t;}) > (if (t && TREE_CODE (t) == ncmp > /* Even though combine_comparisons should > return this, this is to double check. */ > && operand_equal_p (TREE_OPERAND (t, 0), @0) > && operand_equal_p (TREE_OPERAND (t, 1), @1)) > (ncmp @0 @1) > ) > ) > ) > ) > ) > ) > ) > ) > > I am not a fan of it though, I think we should change combine_comparisons to > return the comparison code or true/false or error out. > The loc is due to combine_comparisons building the tree rather than match. > The same is true of the whole checking of the result. I am going to test > this fully and see if there is anything I need to change (there might be > some testcases which need to be "improved"). > > Also the whole ncmp for loop is still another issue which is a genmatch > change to allow a non-name to be there but that is so so much harder to fix > and there is already a case like that too. Yeah, allowing a "computed" code would be nice to support. It shouldn't be _too_ difficult. Do another overload of id_base, like user_id, call it sth like runtime_id - allow it only in replacement context and simply replace with it's variable ID. The only issue is that genmatch can do almost no sanity checking on such cases, it would just need to be a code_helper typed variable.