getMinSignedBits needs to take into consider the sign bit when the value is positive.
authorChris Lattner <sabre@nondot.org>
Wed, 29 Aug 2007 16:21:18 +0000 (16:21 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 29 Aug 2007 16:21:18 +0000 (16:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41566 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h

index 0102d67e07e61f50b5e3e8c9844e93a9be4b180a..9a5643bfc5e1bf4b5b50d59f7a215d4c371550a9 100644 (file)
@@ -856,7 +856,7 @@ public:
   inline uint32_t getMinSignedBits() const {
     if (isNegative())
       return BitWidth - countLeadingOnes() + 1;
-    return getActiveBits();
+    return getActiveBits()+1;
   }
 
   /// This method attempts to return the value of this APInt as a zero extended