http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57656
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 30352 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30352&action=edit patch Fails at -O0 -fstrict-overflow as we fold int t = 1 - (a - b) / c; into int t = (b - a) / c + 1; The change in r117969 exposed a bug in negate_expr_p, namely that we cannot negate (a - b) / c as (b - a) / c because that associates the negate with the division which exposes possible undefined overflow in -(a - b) that is not there in the original expression for c != +-1. This is a bit a problem with the negate_expr_p specification - the API doesn't specify whether we are removing an existing negate or whether we are adding one. This case removes one from the division and adds it to the subtraction. -(a - b) -> (b - a) is ok, but (a - b) -> -(b - a) is not - the API doesn't really distinguish these two cases but in the MINUS_EXPR case clearly implements -(a - b) -> (b - a). Testing the attached.