diff options
author | Tanya Lattner <tonic@nondot.org> | 2007-05-15 05:00:54 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2007-05-15 05:00:54 +0000 |
commit | 5c9213f4014c236be1b75ed8f0889d5a4810594c (patch) | |
tree | e2552aac4921fec2349bc39e409fda552c760b39 | |
parent | 25b919edb616fc0aedd6a6fe509f09b73d789c8e (diff) |
Merge from mainline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_20@37076 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Support/APInt.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 4142c6ec8b..2a35aa057e 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -1199,6 +1199,12 @@ APInt APInt::shl(uint32_t shiftAmt) const { if (shiftAmt == BitWidth) return APInt(BitWidth, 0); + // If none of the bits are shifted out, the result is *this. This avoids a + // lshr by the words size in the loop below which can produce incorrect + // results. It also avoids the expensive computation below for a common case. + if (shiftAmt == 0) + return *this; + // Create some space for the result. uint64_t * val = new uint64_t[getNumWords()]; |