For APInt::z/sext(width), if width == BitWidth, just return *this.
authorZhou Sheng <zhousheng00@gmail.com>
Mon, 12 Mar 2007 17:47:45 +0000 (17:47 +0000)
committerZhou Sheng <zhousheng00@gmail.com>
Mon, 12 Mar 2007 17:47:45 +0000 (17:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35065 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APInt.cpp

index 08ec2362007bb054d6970c1fc268814fe57b717c..ae8f6e4e39542d93ea31391374d6d070fc40aa52 100644 (file)
@@ -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();