Skip to content

Commit 142dce7

Browse files
committed
Dont do popcount in sse2 path either
1 parent 56c34a4 commit 142dce7

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

ext/json/ext/generator/generator.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ typedef struct _search_state {
115115
#ifdef ENABLE_SIMD
116116
const char *chunk_base;
117117
const char *chunk_end;
118-
uint8_t has_matches;
118+
bool has_matches;
119119

120120
#ifdef HAVE_SIMD_NEON
121121
uint64_t matches_mask;
@@ -223,11 +223,8 @@ static inline FORCE_INLINE void escape_UTF8_char_basic(search_state *search)
223223
*/
224224
static inline void convert_UTF8_to_JSON(search_state *search)
225225
{
226-
unsigned char num_chars = 0;
227-
while ((num_chars = search_escape_basic_impl(search))) {
228-
do {
229-
escape_UTF8_char_basic(search);
230-
} while (--num_chars);
226+
while (search_escape_basic_impl(search)) {
227+
escape_UTF8_char_basic(search);
231228
}
232229
}
233230

@@ -510,10 +507,6 @@ static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2(se
510507
continue;
511508
}
512509

513-
if (popcount32(needs_escape_mask) >= sizeof(__m128i)/2) {
514-
return sizeof(__m128i);
515-
}
516-
517510
search->has_matches = 1;
518511
search->matches_mask = needs_escape_mask;
519512
search->chunk_base = search->ptr;
@@ -539,10 +532,6 @@ static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2(se
539532
return 0;
540533
}
541534

542-
if (popcount32(needs_escape_mask) >= sizeof(__m128i)/2) {
543-
return remaining;
544-
}
545-
546535
search->has_matches = 1;
547536
search->matches_mask = needs_escape_mask;
548537
search->chunk_base = search->ptr;

ext/json/ext/generator/simd.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@ static inline int trailing_zeros(int input) {
4848
#endif
4949
}
5050

51-
uint32_t popcount32(uint32_t x) {
52-
#if defined(__GNUC__) || defined(__clang__)
53-
return __builtin_popcount(x);
54-
#elif defined(__ARM_NEON)
55-
#include <arm_neon.h>
56-
return vaddv_u8(vcnt_u8(vcreate_u8((uint64_t)x))) & 0xFF;
57-
#else
58-
x = x - ((x >> 1) & 0x55555555);
59-
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
60-
x = (x + (x >> 4)) & 0x0F0F0F0F;
61-
return (x * 0x01010101) >> 24;
62-
#endif
63-
}
64-
6551
#define SIMD_MINIMUM_THRESHOLD 6
6652

6753
#if defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(__aarch64__) || defined(_M_ARM64)

0 commit comments

Comments
 (0)