Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/art.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
#endif
#endif

#if defined(__i386__) || defined(__amd64__)
/* From http://www.alfredklomp.com/programming/sse-intrinsics/ */
static inline __m128i
_mm_cmpgt_epu8(__m128i x, __m128i y)
{
// Returns 0xFF where x > y:
return _mm_andnot_si128(_mm_cmpeq_epi8(x, y),
_mm_cmpeq_epi8(_mm_max_epu8(x, y), x));
}
static inline __m128i
_mm_cmplt_epu8(__m128i x, __m128i y)
{
// Returns 0xFF where x < y:
return _mm_cmpgt_epu8(y, x);
}
#endif

/**
* Macros to manipulate pointer tags
*/
Expand Down Expand Up @@ -416,7 +433,7 @@ static void add_child16(art_node16 *n, art_node **ref, unsigned char c, void *ch
__m128i cmp;

// Compare the key to all 16 stored keys
cmp = _mm_cmplt_epi8(_mm_set1_epi8(c),
cmp = _mm_cmplt_epu8(_mm_set1_epi8(c),
_mm_loadu_si128((__m128i*)n->keys));

// Use a mask to ignore children that don't exist
Expand All @@ -426,7 +443,7 @@ static void add_child16(art_node16 *n, art_node **ref, unsigned char c, void *ch
__m128i cmp;

// Compare the key to all 16 stored keys
cmp = _mm_cmplt_epi8(_mm_set1_epi8(c),
cmp = _mm_cmplt_epu8(_mm_set1_epi8(c),
_mm_loadu_si128((__m128i*)n->keys));

// Use a mask to ignore children that don't exist
Expand Down