https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123887

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> I'll note that gimplify_cond_expr uses
> !TREE_SIDE_EFFECTS && !generic_expr_could_trap_p but that's not what code
> in fold-const.cc does, but it does not have this kind of simplification
> (on the 7 branch at least).
> 
> The following forces us to do the same on conditional executed match
> captures:
> 
> diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
> index 633ff9e1db2..2f8d85917db 100644
> --- a/gcc/genmatch.cc
> +++ b/gcc/genmatch.cc
> @@ -4384,8 +4384,9 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple,
> operand *result)
>                          & cinfo.force_no_side_effects) == 0)
>               {
>                 fprintf_indent (f, indent,
> -                               "if (TREE_SIDE_EFFECTS (captures[%d])) "
> -                               "goto %s;\n", i, fail_label);
> +                               "if (TREE_SIDE_EFFECTS (captures[%d]) "
> +                               "|| generic_expr_could_trap_p
> (captures[%d])) "
> +                               "goto %s;\n", i, i, fail_label);
>                 needs_label = true;
>                 if (verbose >= 1)
>                   warning_at (cinfo.info[i].c->location,

This has surprising testsuite fallout, so I'm pivoting to the more targeted
fix.

Reply via email to