summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APInt.cpp
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
commit3999ffa0c876efc2763074f805144ecffab9502c (patch)
tree1b25397988833fd571ac9a6837137e6931bdadf5 /llvm/lib/Support/APInt.cpp
parent1791f2380374ca4061d8399e9c248011f51dff9f (diff)
downloadbcm5719-llvm-3999ffa0c876efc2763074f805144ecffab9502c.tar.gz
bcm5719-llvm-3999ffa0c876efc2763074f805144ecffab9502c.zip
For APInt::z/sext(width), if width == BitWidth, just return *this.
llvm-svn: 35065
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 08ec2362007..ae8f6e4e395 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud