[libcxx-commits] [PATCH] D125958: Use __libcpp_clz for a tighter __log2i function
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat May 21 12:38:31 PDT 2022
philnik requested changes to this revision.
philnik added a comment.
The CI failue look unrelated, but I can't recall any problems with the AArch64 CI. Just rebase it and try again. I don't think there are any benchmarks, but it would be nice if you could provide some in `libcxx/benchmarks`. I'd also like to see benchmark results before approving.
================
Comment at: libcxx/include/__algorithm/sort.h:505
+ if (sizeof(__n) <= sizeof(unsigned))
+ return sizeof(unsigned) * __CHAR_BIT__ - 1 - __libcpp_clz(static_cast<unsigned>(__n));
+ if (sizeof(__n) <= sizeof(unsigned long))
----------------
nilayvaish wrote:
> I am wondering whether __CHAR_BIT__ is preferred over using CHAR_BIT (available from climit header file). I don't know what the convention is for writing library code.
I think `CHAR_BIT` is the preferred way. At least that's what I'm using.
================
Comment at: libcxx/include/__algorithm/sort.h:510-516
+
_Number __log2 = 0;
while (__n > 1) {
__log2++;
__n >>= 1;
}
return __log2;
----------------
nilayvaish wrote:
> Instead of retaining this, should we just have a static_assert() on the size of the type being less or equal to that of unsigned long long?
We support `__int128`, so this needs to stay.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125958/new/
https://reviews.llvm.org/D125958
More information about the libcxx-commits
mailing list