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

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #10)
> (In reply to Andrew Pinski from comment #9)
> > So the easy workaround is not use tree_expr_nonnegative_p as predicate here
> > and just do:
> > ```
> >  (simplify
> >   (cmp @0 zerop@1)
> >   (if (tree_expr_nonnegative_p (@0) && !fixed_zerop (@1)
> > ```
> > 
> > Though I am not 100% sure this will workaround all of the issues.
> 
> This also works around the issue:
> ```
> diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
> index b74fb8bb50c..b7e5d32c76d 100644
> --- a/gcc/gimple-fold.cc
> +++ b/gcc/gimple-fold.cc
> @@ -11108,6 +11108,8 @@ gimple_phi_nonnegative_warnv_p (gimple *stmt, bool
> *strict_overflow_p,
>    for (unsigned i = 0; i < gimple_phi_num_args (stmt); ++i)
>      {
>        tree arg = gimple_phi_arg_def (stmt, i);
> +      if (!arg || SSA_NAME_IN_FREE_LIST (arg))
> +       continue;
>        if (!tree_single_nonnegative_warnv_p (arg, strict_overflow_p, depth +
> 1))
>         return false;
>      }
> 
> ```
> 
> But I am not 100% sure if this is correct.

No.

> Is FRE/VN supposed to leave around references to ssa names ih a phi which
> are in the free list even if the block is no longer reachable and depend on
> cleanup cfg?

Yes.  FRE/VN will have turned the conditions into if (0) / if (1) and
relies on CFG cleanup to prune the unreachable parts of the CFG.  FRE/VN
does not bother to update/substitute into unreachable parts of the CFG
as that's a waste of time.

Reply via email to