Skip to content

Commit

Permalink
simd: drop 2 unnecessary instructions (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronO committed May 4, 2023
1 parent efcdae7 commit f34faf2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/simd/avx2.rs
Expand Up @@ -108,10 +108,9 @@ unsafe fn match_header_value_char_32_avx(buf: &[u8]) -> usize {
let tab = _mm256_cmpeq_epi8(dat, TAB);
let del = _mm256_cmpeq_epi8(dat, DEL);
let bit = _mm256_andnot_si256(del, _mm256_or_si256(low, tab));
let rev = _mm256_cmpeq_epi8(bit, _mm256_setzero_si256());
let res = _mm256_movemask_epi8(rev) as u32;

res.trailing_zeros() as usize
let res = _mm256_movemask_epi8(bit) as u32;
// TODO: use .trailing_ones() once MSRV >= 1.46
(!res).trailing_zeros() as usize
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/simd/sse42.rs
Expand Up @@ -97,10 +97,10 @@ unsafe fn match_header_value_char_16_sse(buf: &[u8]) -> usize {
let tab = _mm_cmpeq_epi8(dat, TAB);
let del = _mm_cmpeq_epi8(dat, DEL);
let bit = _mm_andnot_si128(del, _mm_or_si128(low, tab));
let rev = _mm_cmpeq_epi8(bit, _mm_setzero_si128());
let res = _mm_movemask_epi8(rev) as u16;
let res = _mm_movemask_epi8(bit) as u16;

res.trailing_zeros() as usize
// TODO: use .trailing_ones() once MSRV >= 1.46
(!res).trailing_zeros() as usize
}

#[test]
Expand Down

0 comments on commit f34faf2

Please sign in to comment.