diff --git a/libcxx/include/__bit/countl.h b/libcxx/include/__bit/countl.h --- a/libcxx/include/__bit/countl.h +++ b/libcxx/include/__bit/countl.h @@ -74,7 +74,7 @@ int __iter = 0; const unsigned int __ulldigits = numeric_limits::digits; while (true) { - __t = std::__rotr(__t, __ulldigits); + __t = std::__rotl(__t, __ulldigits); if ((__iter = std::__countl_zero(static_cast(__t))) != __ulldigits) break; __ret += __iter; diff --git a/libcxx/include/__bit/rotate.h b/libcxx/include/__bit/rotate.h --- a/libcxx/include/__bit/rotate.h +++ b/libcxx/include/__bit/rotate.h @@ -35,11 +35,16 @@ return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig))); } +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __t, int __cnt) _NOEXCEPT { + return std::__rotr(__t, -__cnt); +} + #if _LIBCPP_STD_VER >= 20 template <__libcpp_unsigned_integer _Tp> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept { - return std::__rotr(__t, -__cnt); + return std::__rotl(__t, __cnt); } template <__libcpp_unsigned_integer _Tp>