From 7f249cd179a12955532ce256c2d36975ae5c320a Mon Sep 17 00:00:00 2001 From: John Keiser Date: Thu, 29 Aug 2019 18:38:41 -0700 Subject: [PATCH] Use non-interleaved map() to make structurals clearer (#304) --- src/haswell/stage1_find_marks.h | 10 ++++++---- src/westmere/stage1_find_marks.h | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/haswell/stage1_find_marks.h b/src/haswell/stage1_find_marks.h index c6e3d345..a054b2d7 100644 --- a/src/haswell/stage1_find_marks.h +++ b/src/haswell/stage1_find_marks.h @@ -72,10 +72,12 @@ really_inline void find_whitespace_and_structurals(simd_input in, whitespace = MAP_BITMASK( in, _mm256_cmpeq_epi8(_in, _mm256_shuffle_epi8(white_table, _in)) ); - auto r1 = MAP_CHUNKS( in, _mm256_add_epi8(struct_offset, _in) ); - auto r2 = MAP_CHUNKS( in, _mm256_or_si256(_in, struct_mask) ); - auto r3 = MAP_CHUNKS( r1, _mm256_shuffle_epi8(structural_table, _r1) ); - structurals = MAP_BITMASK2( r2, r3, _mm256_cmpeq_epi8(_r2, _r3) ); + structurals = in.map([&](auto _in) { + const __m256i r1 = _mm256_add_epi8(struct_offset, _in); + const __m256i r2 = _mm256_or_si256(_in, struct_mask); + const __m256i r3 = _mm256_shuffle_epi8(structural_table, r1); + return _mm256_cmpeq_epi8(r2, r3); + }).to_bitmask(); #endif // else SIMDJSON_NAIVE_STRUCTURAL } diff --git a/src/westmere/stage1_find_marks.h b/src/westmere/stage1_find_marks.h index 50c529d8..27aea6b7 100644 --- a/src/westmere/stage1_find_marks.h +++ b/src/westmere/stage1_find_marks.h @@ -30,10 +30,12 @@ really_inline void find_whitespace_and_structurals(simd_input in, whitespace = MAP_BITMASK( in, _mm_cmpeq_epi8(_in, _mm_shuffle_epi8(white_table, _in)) ); - auto r1 = MAP_CHUNKS( in, _mm_add_epi8(struct_offset, _in) ); - auto r2 = MAP_CHUNKS( in, _mm_or_si128(_in, struct_mask) ); - auto r3 = MAP_CHUNKS( r1, _mm_shuffle_epi8(structural_table, _r1) ); - structurals = MAP_BITMASK2( r2, r3, _mm_cmpeq_epi8(_r2, _r3) ); + structurals = in.map([&](auto _in) { + const __m128i r1 = _mm_add_epi8(struct_offset, _in); + const __m128i r2 = _mm_or_si128(_in, struct_mask); + const __m128i r3 = _mm_shuffle_epi8(structural_table, r1); + return _mm_cmpeq_epi8(r2, r3); + }).to_bitmask(); } #include "generic/stage1_find_marks_flatten.h"