Skip to content

Commit 81cd702

Browse files
[Support] Simplify minIntN and isUIntN (NFC)
1 parent 4c2a9c4 commit 81cd702

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/include/llvm/Support/MathExtras.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ inline constexpr int64_t minIntN(int64_t N) {
225225

226226
if (N == 0)
227227
return 0;
228-
return UINT64_C(1) + ~(UINT64_C(1) << (N - 1));
228+
return UINT64_MAX << (N - 1);
229229
}
230230

231231
/// Gets the maximum value for a N-bit signed integer.
@@ -241,7 +241,7 @@ inline constexpr int64_t maxIntN(int64_t N) {
241241

242242
/// Checks if an unsigned integer fits into the given (dynamic) bit width.
243243
inline constexpr bool isUIntN(unsigned N, uint64_t x) {
244-
return N >= 64 || x <= maxUIntN(N);
244+
return N >= 64 || (x >> N) == 0;
245245
}
246246

247247
/// Checks if an signed integer fits into the given (dynamic) bit width.

0 commit comments

Comments
 (0)