diff options
author | Frits van Bommel <fvbommel@gmail.com> | 2011-03-27 14:26:13 +0000 |
---|---|---|
committer | Frits van Bommel <fvbommel@gmail.com> | 2011-03-27 14:26:13 +0000 |
commit | 6208610fd602ebdb18bb793152899573d0b2b7ab (patch) | |
tree | 04cc9a6f57e3c0b146c2067bd287912b13e4b3e4 /lib/Support | |
parent | f0bf9dfc1f7755a6233e41fd6f259c4ee08a40dc (diff) | |
download | external_llvm-6208610fd602ebdb18bb793152899573d0b2b7ab.zip external_llvm-6208610fd602ebdb18bb793152899573d0b2b7ab.tar.gz external_llvm-6208610fd602ebdb18bb793152899573d0b2b7ab.tar.bz2 |
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
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/APInt.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index f4aae72..5789721 100644 --- a/lib/Support/APInt.cpp +++ b/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) |