summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-03-12 17:47:45 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-03-12 17:47:45 +0000
commit7d820f57e27fc00fafe58cd257ac62e38d68fee5 (patch)
tree12611ebc35715181b600b98ec9a12ff6b88136b5 /lib/Support
parent8cb6834ccfe46279df5f70a9796ba72d8f037bbb (diff)
downloadllvm-7d820f57e27fc00fafe58cd257ac62e38d68fee5.tar.gz
llvm-7d820f57e27fc00fafe58cd257ac62e38d68fee5.tar.bz2
llvm-7d820f57e27fc00fafe58cd257ac62e38d68fee5.tar.xz
For APInt::z/sext(width), if width == BitWidth, just return *this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35065 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/APInt.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 08ec236200..ae8f6e4e39 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -921,6 +921,8 @@ APInt &APInt::trunc(uint32_t width) {
// Sign extend to a new width.
APInt &APInt::sext(uint32_t width) {
+ if (width == BitWidth)
+ return *this;
assert(width > BitWidth && "Invalid APInt SignExtend request");
assert(width <= IntegerType::MAX_INT_BITS && "Too many bits");
// If the sign bit isn't set, this is the same as zext.
@@ -969,6 +971,8 @@ APInt &APInt::sext(uint32_t width) {
// Zero extend to a new width.
APInt &APInt::zext(uint32_t width) {
+ if (width == BitWidth)
+ return *this;
assert(width > BitWidth && "Invalid APInt ZeroExtend request");
assert(width <= IntegerType::MAX_INT_BITS && "Too many bits");
uint32_t wordsBefore = getNumWords();