#[cfg(all(target_arch = "x86_64", feature = "simd"))]
use std::arch::x86_64::*;
#[cfg(all(target_arch = "x86_64", feature = "simd"))]
#[target_feature(enable = "sse2")]
#[inline]
pub unsafe fn match_mask_simd(meta_raw: u64, h2: u8) -> u8 {
let h2 = h2 & 0x7F;
let h0 = ((meta_raw >> 28) & 0x7F) as u8;
let h1 = ((meta_raw >> 35) & 0x7F) as u8;
let h2_2 = ((meta_raw >> 42) & 0x7F) as u8;
let h3 = ((meta_raw >> 49) & 0x7F) as u8;
let h2s = _mm_set_epi8(
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, h3 as i8, h2_2 as i8, h1 as i8, h0 as i8,
);
let target = _mm_set1_epi8(h2 as i8);
let cmp = _mm_cmpeq_epi8(h2s, target);
let h2_match = (_mm_movemask_epi8(cmp) & 0x0F) as u8;
let s0 = ((meta_raw >> 56) & 0x03) as u8;
let s1 = ((meta_raw >> 58) & 0x03) as u8;
let s2 = ((meta_raw >> 60) & 0x03) as u8;
let s3 = ((meta_raw >> 62) & 0x03) as u8;
let full_mask = (s0 == 1) as u8
| (((s1 == 1) as u8) << 1)
| (((s2 == 1) as u8) << 2)
| (((s3 == 1) as u8) << 3);
h2_match & full_mask
}