convert _mm_cmp_epi8_mask to const generics

This commit is contained in:
Rémy Rakic 2021-03-04 22:48:46 +01:00 committed by Amanieu d'Antras
parent 645c4d9b7a
commit a20a17208f

View file

@ -4078,17 +4078,13 @@ pub unsafe fn _mm256_mask_cmp_epi8_mask<const IMM8: i32>(
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_cmp_epi8_mask&expand=705)
#[inline]
#[target_feature(enable = "avx512bw,avx512vl")]
#[rustc_args_required_const(2)]
#[cfg_attr(test, assert_instr(vpcmp, imm8 = 0))]
pub unsafe fn _mm_cmp_epi8_mask(a: __m128i, b: __m128i, imm8: i32) -> __mmask16 {
#[rustc_legacy_const_generics(2)]
#[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))]
pub unsafe fn _mm_cmp_epi8_mask<const IMM8: i32>(a: __m128i, b: __m128i) -> __mmask16 {
static_assert_imm3!(IMM8);
let a = a.as_i8x16();
let b = b.as_i8x16();
macro_rules! call {
($imm3:expr) => {
vpcmpb128(a, b, $imm3, 0b11111111_11111111)
};
}
let r = constify_imm3!(imm8, call);
let r = vpcmpb128(a, b, IMM8, 0b11111111_11111111);
transmute(r)
}
@ -13566,7 +13562,7 @@ mod tests {
unsafe fn test_mm_cmp_epi8_mask() {
let a = _mm_set1_epi8(0);
let b = _mm_set1_epi8(1);
let m = _mm_cmp_epi8_mask(a, b, _MM_CMPINT_LT);
let m = _mm_cmp_epi8_mask::<_MM_CMPINT_LT>(a, b);
assert_eq!(m, 0b11111111_11111111);
}