[llvm] Use Log2_64_Ceil to compute PowerOf2Ceil (PR #67580)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 17:08:13 PDT 2023
https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/67580
>From 537f8af41cef890e3181f9a6b222e74341faed9f Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Wed, 27 Sep 2023 13:34:40 -0400
Subject: [PATCH] Use Log2_64_Ceil to compute PowerOf2Ceil
Instead of calling NextPowerOf2, which is only useful for constants,
we should call Log2_64_Ceil, which is faster because it uses compiler
intrinsics where supported.
---
llvm/include/llvm/Support/MathExtras.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index dc095941fdc8a9f..b3a2825a199e525 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -361,7 +361,7 @@ constexpr inline uint64_t NextPowerOf2(uint64_t A) {
inline uint64_t PowerOf2Ceil(uint64_t A) {
if (!A)
return 0;
- return NextPowerOf2(A - 1);
+ return UINT64_C(1) << Log2_64_Ceil(A);
}
/// Returns the next integer (mod 2**64) that is greater than or equal to
More information about the llvm-commits
mailing list