https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120280
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (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. 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? The reason why we have not hit this before is because this is the first time we have a match pattern which uses tree_expr_nonnegative_p as predicate for a comparison. r6-4002-g4534c2032ba23b was when tree_expr_nonnegative_p added the walk back on phi nodes.