[llvm] c63bbcc - [Support] Simplify isUInt (NFC) (#155976)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 29 09:24:18 PDT 2025
Author: Kazu Hirata
Date: 2025-08-29T09:24:14-07:00
New Revision: c63bbcc32bff9411892e78c786f9ee408f12348a
URL: https://github.com/llvm/llvm-project/commit/c63bbcc32bff9411892e78c786f9ee408f12348a
DIFF: https://github.com/llvm/llvm-project/commit/c63bbcc32bff9411892e78c786f9ee408f12348a.diff
LOG: [Support] Simplify isUInt (NFC) (#155976)
Added:
Modified:
llvm/include/llvm/Support/MathExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index c9dae7ae7346d..96ebbd61e367c 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -196,16 +196,8 @@ constexpr bool isShiftedInt(int64_t x) {
/// Checks if an unsigned integer fits into the given bit width.
template <unsigned N> constexpr bool isUInt(uint64_t x) {
- if constexpr (N == 0)
- return 0 == x;
- if constexpr (N == 8)
- return static_cast<uint8_t>(x) == x;
- if constexpr (N == 16)
- return static_cast<uint16_t>(x) == x;
- if constexpr (N == 32)
- return static_cast<uint32_t>(x) == x;
if constexpr (N < 64)
- return x < (UINT64_C(1) << (N));
+ return (x >> N) == 0;
(void)x; // MSVC v19.25 warns that x is unused.
return true;
}
More information about the llvm-commits
mailing list