Based on the suggestion in https://reviews.llvm.org/D62447?id=201397#inline-554867, this adds a SaturatingInst class that represents the saturating add/sub family of intrinsics. It exposes the same interface as WithOverflowInst, for this reason I have also added a common base class BinaryOpIntrinsic that holds the actual implementation code.
Planned use-sites:
- https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp#L401-L441 Both SaturingInst and the common base class will come in handy to extend this with.overflow code to saturating math.
- https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/InstCombine/InstCombineCalls.cpp#L2058-L2087 can be simplified in conjunction with D62463.