[llvm] 55b5ab1 - [ADT] Use llvm::bit_ceil in SmallPtrSet::reserve (NFC) (#153356)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 13 10:37:09 PDT 2025


Author: Kazu Hirata
Date: 2025-08-13T10:37:06-07:00
New Revision: 55b5ab1d19484dfc27c1c92335cc2d74c68b98b7

URL: https://github.com/llvm/llvm-project/commit/55b5ab1d19484dfc27c1c92335cc2d74c68b98b7
DIFF: https://github.com/llvm/llvm-project/commit/55b5ab1d19484dfc27c1c92335cc2d74c68b98b7.diff

LOG: [ADT] Use llvm::bit_ceil in SmallPtrSet::reserve (NFC) (#153356)

These two expressions are equivalent, and they both internally use
llvm::countl_zero.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/SmallPtrSet.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/SmallPtrSet.h b/llvm/include/llvm/ADT/SmallPtrSet.h
index 28a217afcd0a2..73ec7c68f65ce 100644
--- a/llvm/include/llvm/ADT/SmallPtrSet.h
+++ b/llvm/include/llvm/ADT/SmallPtrSet.h
@@ -129,7 +129,7 @@ class SmallPtrSetImplBase : public DebugEpochBase {
     // We must Grow -- find the size where we'd be 75% full, then round up to
     // the next power of two.
     size_type NewSize = NumEntries + (NumEntries / 3);
-    NewSize = 1 << Log2_32_Ceil(NewSize);
+    NewSize = llvm::bit_ceil(NewSize);
     // Like insert_imp_big, always allocate at least 128 elements.
     NewSize = std::max(128u, NewSize);
     Grow(NewSize);


        


More information about the llvm-commits mailing list