src/pcmp/leq16.h
/**
 * Compares the equality of a mixed case string to a lower case string up
 * to 16 bytes in length.
 *
 * @param  s1  mixed case string to compare
 * @param  s2  lower case string
 * @param  n   length of strings
 * @return  1 if the strings are equal, 0 otherwise
 */
Compares the equality of a mixed case string to a lower case string up
to 16 bytes in length.

@param  s1  mixed case string to compare
@param  s2  lower case string
@param  n   length of strings
@return  1 if the strings are equal, 0 otherwise
Compares the equality of a mixed case string to a lower case string up to 16 bytes in length . @param s1 mixed case string to compare @param s2 lower case string @param n length of strings @return 1 if the strings are equal 0 otherwise
static inline int
pcmp_leq16 (const uint8_t *restrict s1, const uint8_t *restrict s2, int n)
{
	static const uint8_t brng[16] = {'A','Z'};
	static const uint8_t badd[16] = {
		32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32
	};
	__m128i rng = _mm_loadu_si128 ((const __m128i *)(void *)brng);
	__m128i add = _mm_loadu_si128 ((const __m128i *)(void *)badd);
	__m128i zer = _mm_setzero_si128 ();
	__m128i m1, m2, mask;
	m1 = _mm_lddqu_si128 ((const __m128i *)(void *)s1);
	mask = _mm_cmpestrm (rng, 2, m1, n,
			_SIDD_CMP_RANGES | _SIDD_UNIT_MASK);
	mask = _mm_blendv_epi8 (zer, add, mask);
	m1 = _mm_add_epi8 (m1, mask);
	m2 = _mm_lddqu_si128 ((const __m128i *)(void *)s2);
	return (n == _mm_cmpestri (
				m1, n, m2, 16,
				_SIDD_CMP_EQUAL_EACH | _SIDD_MASKED_NEGATIVE_POLARITY));
}
static inline int pcmp_leq16 ( const uint8_t * restrict s1 , const uint8_t * restrict s2 , int n ) { static const uint8_t brng [ 16 ] = { ' ' , ' ' } ; static const uint8_t badd [ 16 ] = { 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 } ; __m128i rng = _mm_loadu_si128 ( ( const __m128i * ) ( void * ) brng ) ; __m128i add = _mm_loadu_si128 ( ( const __m128i * ) ( void * ) badd ) ; __m128i zer = _mm_setzero_si128 ( ) ; __m128i m1 , m2 , mask ; m1 = _mm_lddqu_si128 ( ( const __m128i * ) ( void * ) s1 ) ; mask = _mm_cmpestrm ( rng , 2 , m1 , n , _SIDD_CMP_RANGES | _SIDD_UNIT_MASK ) ; mask = _mm_blendv_epi8 ( zer , add , mask ) ; m1 = _mm_add_epi8 ( m1 , mask ) ; m2 = _mm_lddqu_si128 ( ( const __m128i * ) ( void * ) s2 ) ; return ( n == _mm_cmpestri ( m1 , n , m2 , 16 , _SIDD_CMP_EQUAL_EACH | _SIDD_MASKED_NEGATIVE_POLARITY ) ) ; }
Compares the equality of a mixed case string to a lower case string up
 to 16 bytes in length.
Compares the equality of a mixed case string to a lower case string up to 16 bytes in length .
// load mixed case string // mask has 255 for each upper case character and 0 for the rest // change each 255 to 32 // add mask to string which changes upper case to lower // load lower case string // compare strings and find the last matched index