Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

We can drop kValue > 0 in CTLog2 because llvm::isPowerOf2_64 returns
false on input 0.

We can drop kValue > 0 in CTLog2 because llvm::isPowerOf2_64 returns
false on input 0.
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2025

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

Changes

We can drop kValue > 0 in CTLog2 because llvm::isPowerOf2_64 returns
false on input 0.


Full diff: https://github.com/llvm/llvm-project/pull/143559.diff

1 Files Affected:

  • (modified) llvm/include/llvm/Support/MathExtras.h (+1-2)
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>();
 }
 

@kazutakahirata kazutakahirata merged commit 04cffaa into llvm:main Jun 10, 2025
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250610_llvm_has_single_bit branch June 10, 2025 18:31
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
We can drop kValue > 0 in CTLog2 because llvm::isPowerOf2_64 returns
false on input 0.
akuhlens pushed a commit to akuhlens/llvm-project that referenced this pull request Jun 24, 2025
We can drop kValue > 0 in CTLog2 because llvm::isPowerOf2_64 returns
false on input 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants