Skip to content

Commit c63bbcc

Browse files
[Support] Simplify isUInt (NFC) (#155976)
1 parent f7ef199 commit c63bbcc

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

llvm/include/llvm/Support/MathExtras.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,8 @@ constexpr bool isShiftedInt(int64_t x) {
196196

197197
/// Checks if an unsigned integer fits into the given bit width.
198198
template <unsigned N> constexpr bool isUInt(uint64_t x) {
199-
if constexpr (N == 0)
200-
return 0 == x;
201-
if constexpr (N == 8)
202-
return static_cast<uint8_t>(x) == x;
203-
if constexpr (N == 16)
204-
return static_cast<uint16_t>(x) == x;
205-
if constexpr (N == 32)
206-
return static_cast<uint32_t>(x) == x;
207199
if constexpr (N < 64)
208-
return x < (UINT64_C(1) << (N));
200+
return (x >> N) == 0;
209201
(void)x; // MSVC v19.25 warns that x is unused.
210202
return true;
211203
}

0 commit comments

Comments
 (0)