https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > The problem is that twoval_comparison_p breaks appart SAVE_EXPR if their > argument has no side effects. > First, cp_build_binary_op calls save_expr on: > (__builtin_expect ((long int) (# DEBUG BEGIN STMT; > x != 0; ? 0 : 1), (long int) NON_LVALUE_EXPR <3>) == 0) * -1; > and that resulting SAVE_EXPR is used in 2+ places, where one of them is a > comparison against INTEGER_CST, which is optimized using twoval_comparison_p > as > another SAVE_EXPR with > __builtin_expect ((long int) (# DEBUG BEGIN STMT; > x != 0; ? 0 : 1), (long int) NON_LVALUE_EXPR <3>) == 0; > body. As mostly_copy_tree_r does not unshare STATEMENT_LISTs, we hand over > to the gimplifier the above two SAVE_EXPRs and both contain the same > STATEMENT_LIST, so we try to gimplify it twice, which as we know from other > PRs doesn't really work at all. > Now, not looking through SAVE_EXPRs in twoval_comparison_p if it contains a > STATEMENT_LIST might result in -fcompare-debug failures, because with -g0 > there could be no STATEMENT_LIST, while with -g we have one. > Not sure what our options are, besides just killing the SAVE_EXPR handling > in twoval_comparison_p. unshare the expression in twoval_comparison_p?