Fix isIntN to work with APInts > 64 bits. This method is only
authorChris Lattner <sabre@nondot.org>
Tue, 2 Dec 2008 23:33:29 +0000 (23:33 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 2 Dec 2008 23:33:29 +0000 (23:33 +0000)
used by clang apparently.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60446 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h

index 1799b21b183e44c6b9bf1097ad6f7e2cb757221a..3c16b3841ef4cd595f20d415c46316f46732017b 100644 (file)
@@ -333,12 +333,14 @@ public:
   /// @brief Check if this APInt has an N-bits unsigned integer value.
   bool isIntN(uint32_t N) const {
     assert(N && "N == 0 ???");
-    if (isSingleWord()) {
+    if (N >= getBitWidth())
+      return true;
+    
+    if (isSingleWord())
       return VAL == (VAL & (~0ULL >> (64 - N)));
-    } else {
-      APInt Tmp(N, getNumWords(), pVal);
-      return Tmp == (*this);
-    }
+    APInt Tmp(N, getNumWords(), pVal);
+    Tmp.zext(getBitWidth());
+    return Tmp == (*this);
   }
 
   /// @brief Check if this APInt has an N-bits signed integer value.