In isUIntN, make sure N is less than 64 before using in a shift to avoid undefined...
authorCraig Topper <craig.topper@gmail.com>
Sat, 10 Oct 2015 18:54:26 +0000 (18:54 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 10 Oct 2015 18:54:26 +0000 (18:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249951 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/MathExtras.h

index 71b22b0f2fcf2b67adf10aab6eb38d060195ffa9..2c515bbd242a13b725b37c5ad30ad4478a836418 100644 (file)
@@ -313,7 +313,7 @@ inline bool isShiftedUInt(uint64_t x) {
 /// isUIntN - Checks if an unsigned integer fits into the given (dynamic)
 /// bit width.
 inline bool isUIntN(unsigned N, uint64_t x) {
-  return x == (x & (~0ULL >> (64 - N)));
+  return N >= 64 || x < (UINT64_C(1)<<(N));
 }
 
 /// isIntN - Checks if an signed integer fits into the given (dynamic)