This patch uses LVI to lower x.with.overflow intrinsics to the corresponding nsw instructions when an overflow provably doesn't occur. It fires about 1800 times while building LLVM with -fsanitize=signed-integer-overflow. It should fire more but it appears to be blocked by the precision of LVI's results. It looks like LVI needs a lot of fine tuning.
I consider this patch fairly low risk since it doesn't do anything unless there are integer overflow checks to look at.
I've done some testing and will continue to do more. Obviously I need to add test cases to the patch, but thought I would seek some initial feedback on the code first.
/// Doxygen. And LLVM style.
Having this take an Instruction would make this easy to extend to proving nsw/nuw on adds.
Also, clarify what *kind* of overflow you're proving.