[llvm] 04cffaa - [Support] Simplify CTLog2 (NFC) (#143559)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 10 11:31:42 PDT 2025
Author: Kazu Hirata
Date: 2025-06-10T11:31:39-07:00
New Revision: 04cffaae8f6110da7c5808a4f8107331357f56e4
URL: https://github.com/llvm/llvm-project/commit/04cffaae8f6110da7c5808a4f8107331357f56e4
DIFF: https://github.com/llvm/llvm-project/commit/04cffaae8f6110da7c5808a4f8107331357f56e4.diff
LOG: [Support] Simplify CTLog2 (NFC) (#143559)
We can drop kValue > 0 in CTLog2 because llvm::isPowerOf2_64 returns
false on input 0.
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 246080aa45ce0..ae3150e5602ee 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -328,8 +328,7 @@ inline bool isShiftedMask_64(uint64_t Value, unsigned &MaskIdx,
/// Compile time Log2.
/// Valid only for positive powers of two.
template <size_t kValue> constexpr size_t CTLog2() {
- static_assert(kValue > 0 && llvm::isPowerOf2_64(kValue),
- "Value is not a valid power of 2");
+ static_assert(llvm::isPowerOf2_64(kValue), "Value is not a valid power of 2");
return 1 + CTLog2<kValue / 2>();
}
More information about the llvm-commits
mailing list