APInt swift::constantFoldBinaryWithOverflow(APInt lhs, APInt rhs, bool &Overflow, llvm::Intrinsic::ID ID) { switch (ID) { default: llvm_unreachable("Invalid case"); case llvm::Intrinsic::sadd_with_overflow: return lhs.sadd_ov(rhs, Overflow); case llvm::Intrinsic::uadd_with_overflow: return lhs.uadd_ov(rhs, Overflow); case llvm::Intrinsic::ssub_with_overflow: return lhs.ssub_ov(rhs, Overflow); case llvm::Intrinsic::usub_with_overflow: return lhs.usub_ov(rhs, Overflow); case llvm::Intrinsic::smul_with_overflow: return lhs.smul_ov(rhs, Overflow); case llvm::Intrinsic::umul_with_overflow: return lhs.umul_ov(rhs, Overflow); } }