https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83239
--- Comment #14 from Jeffrey A. Law <law at redhat dot com> --- You *really* don't want to do this with a match.pd pattern. Recovering the arith-with-overflow optimizations is virtually impossible in the general case. All that really needs to be done here is generalize existing code that currently handles overflow tests with +-1 to handle them more generically. In fact doing so actually removes code since we had separate cases for +1 and -1 generating an overflow.