https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37516
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
A match.pd rule should be reasonably easy to write. Beware that ~a is not
undefined but -a - 1 might be if it overflows. That is
(simplify
(bit_not (minus INTEGER_CST@0 @1))
(plus @1 (minus (negate @0) { build_one_cst (type); }))
with the constant folding done at compile-time, caring for overflow in the
constant term. As said, not sure how to avoid @1 + new-cst from overflowing.
