From 1059f2a237ba8f587bb0745f3fdbe24179f0f862 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 12 Feb 2024 17:32:05 -0800 Subject: [PATCH] Use std::countr_zero --- ConflictSet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index c0707b9..51b24a1 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -791,7 +791,7 @@ int firstNeqStride(const uint8_t *ap, const uint8_t *bp) { const auto compared = _mm_cmpeq_epi8(a, b); c[i / 16] = _mm_movemask_epi8(compared) & 0xffff; } - return __builtin_ctzll(~(c[0] | c[1] << 16 | c[2] << 32 | c[3] << 48)); + return std::countr_zero(~(c[0] | c[1] << 16 | c[2] << 32 | c[3] << 48)); #elif defined(HAS_ARM_NEON) static_assert(kStride == 64); for (int i = 0; i < kStride; i += 16) { @@ -802,7 +802,7 @@ int firstNeqStride(const uint8_t *ap, const uint8_t *bp) { uint64_t bitfield = ~vget_lane_u64(vreinterpret_u64_u8(vshrn_n_u16(results, 4)), 0); if (bitfield) { - return i + (__builtin_ctzll(bitfield) >> 2); + return i + (std::countr_zero(bitfield) >> 2); } } __builtin_unreachable(); @@ -833,7 +833,7 @@ int longestCommonPrefix(const uint8_t *ap, const uint8_t *bp, int cl) { memcpy(&b, bp, 8); const auto mismatched = a ^ b; if (mismatched) { - return __builtin_ctzll(mismatched) / 8; + return std::countr_zero(mismatched) / 8; } } @@ -870,7 +870,7 @@ int longestCommonPrefix(const uint8_t *ap, const uint8_t *bp, int cl) { memcpy(&b, bp, 8); const auto mismatched = a ^ b; if (mismatched) { - return i + __builtin_ctzll(mismatched) / 8; + return i + std::countr_zero(mismatched) / 8; } i += 8; ap += 8;