Engine/source/persistence/rapidjson/reader.h
//! Skip whitespace with SSE 4.2 pcmpistrm instruction, testing 16 8-byte characters at once.
Skip whitespace with SSE 4.2 pcmpistrm instruction, testing 16 8-byte characters at once.
Skip whitespace with SSE 4 . 2 pcmpistrm instruction testing 16 8 - byte characters at once .
inline const char *SkipWhitespace_SIMD(const char* p) {
	static const char whitespace[16] = " \n\r\t";
	__m128i w = _mm_loadu_si128((const __m128i *)&whitespace[0]);
	for (;;) {
		__m128i s = _mm_loadu_si128((const __m128i *)p);
		unsigned r = _mm_cvtsi128_si32(_mm_cmpistrm(w, s, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY));
		if (r == 0)	
			p += 16;
		else {		
#ifdef _MSC_VER		
			unsigned long offset;
			if (_BitScanForward(&offset, r))
				return p + offset;
#else
			if (r != 0)
				return p + __builtin_ffs(r) - 1;
#endif
		}
	}
}
inline const char * SkipWhitespace_SIMD ( const char * p ) { static const char whitespace [ 16 ] = " \n \r \t " ; __m128i w = _mm_loadu_si128 ( ( const __m128i * ) & whitespace [ 0 ] ) ; for ( ; ; ) { __m128i s = _mm_loadu_si128 ( ( const __m128i * ) p ) ; unsigned r = _mm_cvtsi128_si32 ( _mm_cmpistrm ( w , s , _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY ) ) ; if ( r == 0 ) p += 16 ; else { #ifdef _MSC_VER unsigned long offset ; if ( _BitScanForward ( & offset , r ) ) return p + offset ; #else if ( r != 0 ) return p + __builtin_ffs ( r ) - 1 ; #endif } } }
Skip whitespace with SSE 4.2 pcmpistrm instruction, testing 16 8-byte characters at once.
Skip whitespace with SSE 4 . 2 pcmpistrm instruction testing 16 8 - byte characters at once .
// all 16 characters are whitespace // some of characters may be non-whitespace // Find the index of first non-whitespace