From 6208610fd602ebdb18bb793152899573d0b2b7ab 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128379 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/APInt.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/Support') 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) -- cgit v1.1