@@ -36,29 +36,29 @@ namespace xsimd
3636 XSIMD_INLINE size_t countl_zero (batch_bool<T, A> const & self, requires_arch<common>) noexcept
3737 {
3838 constexpr size_t unused_bits = 64 - batch_bool<T, A>::size;
39- constexpr uint64_t lower_mask = batch_bool<T, A>::size < 64 ? ((uint64_t )1 << batch_bool<T, A>::size) - 1 : (uint64_t )-1 ;
39+ constexpr uint64_t lower_mask = batch_bool<T, A>::size < 64 ? ((uint64_t )1 << ( batch_bool<T, A>::size % 64 ) ) - 1 : (uint64_t )-1 ;
4040 return xsimd::detail::countl_zero (self.mask () & lower_mask) - unused_bits;
4141 }
4242
4343 template <class A , class T >
4444 XSIMD_INLINE size_t countl_one (batch_bool<T, A> const & self, requires_arch<common>) noexcept
4545 {
4646 constexpr size_t unused_bits = 64 - batch_bool<T, A>::size;
47- constexpr uint64_t upper_mask = batch_bool<T, A>::size < 64 ? ~(((uint64_t )1 << batch_bool<T, A>::size) - 1 ) : (uint64_t )0 ;
47+ constexpr uint64_t upper_mask = batch_bool<T, A>::size < 64 ? ~(((uint64_t )1 << ( batch_bool<T, A>::size % 64 ) ) - 1 ) : (uint64_t )0 ;
4848 return xsimd::detail::countl_one (self.mask () | upper_mask) - unused_bits;
4949 }
5050
5151 template <class A , class T >
5252 XSIMD_INLINE size_t countr_zero (batch_bool<T, A> const & self, requires_arch<common>) noexcept
5353 {
54- constexpr uint64_t stop = batch_bool<T, A>::size < 64 ? (uint64_t )1 << batch_bool<T, A>::size : 0 ;
54+ constexpr uint64_t stop = batch_bool<T, A>::size < 64 ? (uint64_t )1 << ( batch_bool<T, A>::size % 64 ) : 0 ;
5555 return xsimd::detail::countr_zero (self.mask () | stop);
5656 }
5757
5858 template <class A , class T >
5959 XSIMD_INLINE size_t countr_one (batch_bool<T, A> const & self, requires_arch<common>) noexcept
6060 {
61- constexpr uint64_t stop = batch_bool<T, A>::size < 64 ? ~((uint64_t )1 << batch_bool<T, A>::size) : (uint64_t )-1 ;
61+ constexpr uint64_t stop = batch_bool<T, A>::size < 64 ? ~((uint64_t )1 << ( batch_bool<T, A>::size % 64 ) ) : (uint64_t )-1 ;
6262 return xsimd::detail::countr_one (self.mask () & stop);
6363 }
6464
0 commit comments