https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68528
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- at -O0 we have in .original int t = 1; because when we fold INT_MIN - (int) ((unsigned int) x0 - (unsigned int) x1) we go through /* A - B -> A + (-B) if B is easily negatable. */ if (negate_expr_p (arg1) && !TYPE_OVERFLOW_SANITIZED (type) && ((FLOAT_TYPE_P (type) /* Avoid this transformation if B is a positive REAL_CST. */ && (TREE_CODE (arg1) != REAL_CST || REAL_VALUE_NEGATIVE (TREE_REAL_CST (arg1)))) || INTEGRAL_TYPE_P (type))) return fold_build2_loc (loc, PLUS_EXPR, type, fold_convert_loc (loc, type, arg0), fold_convert_loc (loc, type, negate_expr (arg1))); resulting in (int) ((unsigned int) x1 - (unsigned int) x0) + -2147483648 after canonicalization which can never be zero (considering undefined overflow) and we determine that from /* Transform comparisons of the form X +- C1 CMP C2 to X CMP C2 -+ C1. */ if ((TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) == MINUS_EXPR) && (equality_code || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (arg0)) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg0)))) && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST && !TREE_OVERFLOW (TREE_OPERAND (arg0, 1)) && TREE_CODE (arg1) == INTEGER_CST && !TREE_OVERFLOW (arg1)) { const enum tree_code reverse_op = TREE_CODE (arg0) == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR; tree const1 = TREE_OPERAND (arg0, 1); tree const2 = fold_convert_loc (loc, TREE_TYPE (const1), arg1); tree variable = TREE_OPERAND (arg0, 0); tree new_const = int_const_binop (reverse_op, const2, const1); /* If the constant operation overflowed this can be simplified as a comparison against INT_MAX/INT_MIN. */ if (TREE_OVERFLOW (new_const) && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0))) { ... /* We now can look at the canonicalized case VARIABLE + 1 CODE2 INT_MIN and decide on the result. */