This handles them by not simplifying anything (for now). It also fixes two warnings that prevent bootstrap.
Committed. Richard. 2014-07-15 Richard Biener <rguent...@suse.de> * genmatch.c (decision_tree::gen_generic): Reject operands with TREE_SIDE_EFFECTS for now. (parse_for): Drop name of unused parameter. (main): Remove unused token. * match.pd: Remove ??? comment about TREE_SIDE_EFFECTS. Index: gcc/genmatch.c =================================================================== --- gcc/genmatch.c (revision 212542) +++ gcc/genmatch.c (working copy) @@ -1608,6 +1608,18 @@ decision_tree::gen_generic (FILE *f) fprintf (f, ")\n"); fprintf (f, "{\n"); + /* ??? For now reject all simplifications on operands with + side-effects as we are not prepared to properly wrap + omitted parts with omit_one_operand and friends. In + principle we can do that automagically for a subset of + transforms (and only reject the remaining cases). + This fixes for example gcc.c-torture/execute/20050131-1.c. */ + fprintf (f, "if (TREE_SIDE_EFFECTS (op0)"); + for (unsigned i = 1; i < n; ++i) + fprintf (f, "|| TREE_SIDE_EFFECTS (op%d)", i); + fprintf (f, ")\n" + " return NULL_TREE;\n"); + fprintf (f, "switch (code)\n" "{\n"); for (unsigned i = 0; i < root->kids.length (); i++) @@ -2013,7 +2025,7 @@ parse_match_and_simplify (cpp_reader *r, } void -parse_for (cpp_reader *r, source_location match_location, vec<simplify *>& simplifiers) +parse_for (cpp_reader *r, source_location, vec<simplify *>& simplifiers) { const char *user_id = get_ident (r); eat_ident (r, "in"); @@ -2074,7 +2086,6 @@ int main(int argc, char **argv) { cpp_reader *r; - const cpp_token *token; progname = "genmatch"; Index: gcc/match.pd =================================================================== --- gcc/match.pd (revision 212542) +++ gcc/match.pd (working copy) @@ -46,11 +46,7 @@ along with GCC; see the file COPYING3. (trunc_mod @0 integer_onep) { build_zero_cst (type); }) /* Same applies to modulo operations, but fold is inconsistent here - and simplifies 0 % x to 0. - ??? This also shows an issue with the GENERIC case - we have to - pass all dropped through omit_{one,two}_operand{,s} to preserve - their side-effects - seen gcc.c-torture/execute/20050131-1.c - execute failure. Eventually we can autodetect this. */ + and simplifies 0 % x to 0. */ (match_and_simplify (trunc_mod integer_zerop@0 @1) if (!integer_zerop (@1))