https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106163
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2022-07-04 Status|UNCONFIRMED |NEW CC| |rguenth at gcc dot gnu.org Keywords| |wrong-code --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. It's not entirely clear to me if exceptions need to be marked as side-effect in GENERIC (when there's no explicit CFG or EH representation). In genmatch it's probably /* Generate matching code for the decision tree operand which is a capture-match. */ unsigned dt_operand::gen_match_op (FILE *f, int indent, const char *opname, bool) { char match_opname[20]; match_dop->get_name (match_opname); if (value_match) fprintf_indent (f, indent, "if ((%s == %s && ! TREE_SIDE_EFFECTS (%s)) " "|| operand_equal_p (%s, %s, 0))\n", opname, match_opname, opname, opname, match_opname); else fprintf_indent (f, indent, "if ((%s == %s && ! TREE_SIDE_EFFECTS (%s)) " "|| (operand_equal_p (%s, %s, 0) " "&& types_match (%s, %s)))\n", opname, match_opname, opname, opname, match_opname, opname, match_opname); fprintf_indent (f, indent + 2, "{\n"); return 1; where you can see the that we defer to operand_equal_p or do what that does for the case of tree sharing (test TREE_SIDE_EFFECTS). The issue is probably latent since even before match.pd (for GENERIC, that is), so the fix probably needs to extend to operand_equal_p. That said, there's somewhat of a point in the trees lacking TREE_SIDE_EFFECTS, but of course an explicit honoring of tree_could_throw_p might be possible as well.