Use std::countr_zero

This commit is contained in:
2024-02-12 17:32:05 -08:00
parent d5bde56921
commit 1059f2a237

View File

@@ -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;