convert _mm512_cmp_epu8_mask to const generics

This commit is contained in:
Rémy Rakic 2021-03-04 22:33:56 +01:00 committed by Amanieu d'Antras
parent 93c35b0844
commit 09face908b

View file

@ -3796,22 +3796,18 @@ pub unsafe fn _mm_mask_cmp_epu16_mask<const IMM8: i32>(
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm512_cmp_epu8_mask&expand=733)
#[inline]
#[target_feature(enable = "avx512bw")]
#[rustc_args_required_const(2)]
#[cfg_attr(test, assert_instr(vpcmp, imm8 = 0))]
pub unsafe fn _mm512_cmp_epu8_mask(a: __m512i, b: __m512i, imm8: i32) -> __mmask64 {
#[rustc_legacy_const_generics(2)]
#[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))]
pub unsafe fn _mm512_cmp_epu8_mask<const IMM8: i32>(a: __m512i, b: __m512i) -> __mmask64 {
static_assert_imm3!(IMM8);
let a = a.as_u8x64();
let b = b.as_u8x64();
macro_rules! call {
($imm3:expr) => {
vpcmpub(
a,
b,
$imm3,
0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111,
)
};
}
let r = constify_imm3!(imm8, call);
let r = vpcmpub(
a,
b,
IMM8,
0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111,
);
transmute(r)
}
@ -13485,7 +13481,7 @@ mod tests {
unsafe fn test_mm512_cmp_epu8_mask() {
let a = _mm512_set1_epi8(0);
let b = _mm512_set1_epi8(1);
let m = _mm512_cmp_epu8_mask(a, b, _MM_CMPINT_LT);
let m = _mm512_cmp_epu8_mask::<_MM_CMPINT_LT>(a, b);
assert_eq!(
m,
0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111