Skip to content

Commit 1c6ee3d

Browse files
committed
A few tweaks to the SSE algorithm.
1 parent 4970255 commit 1c6ee3d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

ext/json/ext/generator/generator.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,10 @@ static inline unsigned char search_escape_basic_neon(search_state *search)
489489

490490
#ifdef HAVE_SIMD_SSE2
491491

492-
// #define _mm_cmpge_epu8(a, b) _mm_cmpeq_epi8(_mm_max_epu8(a, b), a)
493-
// #define _mm_cmple_epu8(a, b) _mm_cmpge_epu8(b, a)
494-
// #define _mm_cmpgt_epu8(a, b) _mm_xor_si128(_mm_cmple_epu8(a, b), _mm_set1_epi8(-1))
495-
// #define _mm_cmplt_epu8(a, b) _mm_cmpgt_epu8(b, a)
492+
#define _mm_cmpge_epu8(a, b) _mm_cmpeq_epi8(_mm_max_epu8(a, b), a)
493+
#define _mm_cmple_epu8(a, b) _mm_cmpge_epu8(b, a)
494+
#define _mm_cmpgt_epu8(a, b) _mm_xor_si128(_mm_cmple_epu8(a, b), _mm_set1_epi8(-1))
495+
#define _mm_cmplt_epu8(a, b) _mm_cmpgt_epu8(b, a)
496496

497497
static inline unsigned char sse2_next_match(search_state *search) {
498498
int mask = search->matches_mask;
@@ -526,16 +526,16 @@ static inline __m128i sse2_update(__m128i chunk) {
526526
const __m128i lower_bound = _mm_set1_epi8(' ');
527527
const __m128i backslash = _mm_set1_epi8('\\');
528528
const __m128i dblquote = _mm_set1_epi8('\"');
529-
const __m128i high_bit = _mm_set1_epi8(0x80);
529+
// const __m128i high_bit = _mm_set1_epi8(0x80);
530530

531-
// __m128i too_low = _mm_cmplt_epu8(chunk, lower_bound);
531+
__m128i too_low = _mm_cmplt_epu8(chunk, lower_bound);
532532

533-
// This is a signed comparison. We need special handling for bytes > 127.
534-
__m128i too_low = _mm_cmplt_epi8(chunk, lower_bound);
533+
// // This is a signed comparison. We need special handling for bytes > 127.
534+
// __m128i too_low = _mm_cmplt_epi8(chunk, lower_bound);
535535

536-
// Determine which bytes have the high bit set and remove them from 'too_low'.
537-
__m128i high_bit_set = _mm_cmpeq_epi8(_mm_and_si128(chunk, high_bit), high_bit);
538-
too_low = _mm_andnot_si128(high_bit_set, too_low);
536+
// // Determine which bytes have the high bit set and remove them from 'too_low'.
537+
// __m128i high_bit_set = _mm_cmpeq_epi8(_mm_and_si128(chunk, high_bit), high_bit);
538+
// too_low = _mm_andnot_si128(high_bit_set, too_low);
539539

540540
__m128i has_backslash = _mm_cmpeq_epi8(chunk, backslash);
541541
__m128i has_dblquote = _mm_cmpeq_epi8(chunk, dblquote);

0 commit comments

Comments
 (0)