In isUIntN, make sure N is less than 64 before using in a shift to avoid undefined behavior. Also change it to use the same formula as the template version which I think results in less math in compiled code.

llvm-svn: 249951
This commit is contained in:
Craig Topper 2015-10-10 18:54:26 +00:00
parent 114aae4ac7
commit 798cc60ad9
1 changed files with 1 additions and 1 deletions

View 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)