From 32ce06bbf2cf0392fd5f3d147b6640f76f864230 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 22 Jan 2023 14:34:43 -0800 Subject: [PATCH] [Support] Use llvm::bit_floor in PowerOf2Floor (NFC) --- llvm/include/llvm/Support/MathExtras.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h index b2b2721..ff136ba 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -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. -- 2.7.4