Constant folding support for calls to umul.with.overflow(), basically identical to the smul.with.overflow() code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frits van Bommel
2011-03-27 14:26:13 +00:00
parent f0bf9dfc1f
commit 6208610fd6
4 changed files with 52 additions and 11 deletions
+10
View File
@@ -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)