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:
parent
114aae4ac7
commit
798cc60ad9
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue