From 0bb2ad2cf7f8032492401d82e0cb6be6b98406a0 Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Sun, 27 Mar 2011 14:26:13 +0000 Subject: Constant folding support for calls to umul.with.overflow(), basically identical to the smul.with.overflow() code. llvm-svn: 128379 --- llvm/lib/Support/APInt.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'llvm/lib/Support/APInt.cpp') diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index f4aae72..5789721 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -2078,6 +2078,16 @@ APInt APInt::smul_ov(const APInt &RHS, bool &Overflow) const { return Res; } +APInt APInt::umul_ov(const APInt &RHS, bool &Overflow) const { + APInt Res = *this * RHS; + + if (*this != 0 && RHS != 0) + Overflow = Res.udiv(RHS) != *this || Res.udiv(*this) != RHS; + else + Overflow = false; + return Res; +} + APInt APInt::sshl_ov(unsigned ShAmt, bool &Overflow) const { Overflow = ShAmt >= getBitWidth(); if (Overflow) -- cgit v1.1