[Support] Use llvm::bit_floor in PowerOf2Floor (NFC)
authorKazu Hirata <kazu@google.com>
Sun, 22 Jan 2023 22:34:43 +0000 (14:34 -0800)
committerKazu Hirata <kazu@google.com>
Sun, 22 Jan 2023 22:34:43 +0000 (14:34 -0800)
llvm/include/llvm/Support/MathExtras.h

index b2b2721..ff136ba 100644 (file)
@@ -483,8 +483,7 @@ constexpr inline uint64_t NextPowerOf2(uint64_t A) {
 /// Returns the power of two which is less than or equal to the given value.
 /// Essentially, it is a floor operation across the domain of powers of two.
 inline uint64_t PowerOf2Floor(uint64_t A) {
-  if (!A) return 0;
-  return 1ull << (63 - llvm::countl_zero(A));
+  return llvm::bit_floor(A);
 }
 
 /// Returns the power of two which is greater than or equal to the given value.