[libcxx-commits] [libcxx] [libc++][bit] Improves rotate functions. (PR #98032)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 30 10:30:53 PDT 2024
================
@@ -20,24 +20,37 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// Writing two full functions for rotl and rotr makes it easier for the compiler
+// to optimize the code. On x86 this function becomes the ROL instruction and
+// the rotr function becomes the ROR instruction.
template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __t, int __cnt) _NOEXCEPT {
- static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
- const unsigned int __dig = numeric_limits<_Tp>::digits;
----------------
mordante wrote:
Seems I didn't submit my comment before. We typically don't use `const` at all. The code was based on the original code. I'll changes it as suggested by Louis.
https://github.com/llvm/llvm-project/pull/98032
More information about the libcxx-commits
mailing list