https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92712
--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Marc Glisse from comment #16) > (In reply to Jakub Jelinek from comment #15) > > I guess we could handle those cases by using something like > > check_for_binary_op_overflow, except that for the case where A might be -1 > > and plusminus equal to MINUS_EXPR we also need to make sure the result of > > B-C is known not to be min. > > You may not need to worry about the multiplication overflowing. If a*b+a*c > and b+c are computed with an undefined overflow type and do not overflow, > then a*(b+c) cannot overflow either. Yes, see above, for a*b+-a*c the only cases where UB would be introduced is when b+-c overflows (but a subset of that, if we knew that a is not 0, we could do better, as then all we care about is that (unsigned)(b+-c) didn't overflow to INT_MIN).