convert _mm256_mask_shufflehi_epi16 to const generics

This commit is contained in:
Rémy Rakic 2021-03-05 00:51:41 +01:00 committed by Amanieu d'Antras
parent c575dfa6f9
commit 033b05edfc

View file

@ -7376,20 +7376,15 @@ pub unsafe fn _mm512_maskz_shufflehi_epi16<const IMM8: i32>(k: __mmask32, a: __m
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_mask_shufflehi_epi16&expand=5207)
#[inline]
#[target_feature(enable = "avx512bw,avx512vl")]
#[cfg_attr(test, assert_instr(vpshufhw, imm8 = 5))]
#[rustc_args_required_const(3)]
pub unsafe fn _mm256_mask_shufflehi_epi16(
#[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 5))]
#[rustc_legacy_const_generics(3)]
pub unsafe fn _mm256_mask_shufflehi_epi16<const IMM8: i32>(
src: __m256i,
k: __mmask16,
a: __m256i,
imm8: i32,
) -> __m256i {
macro_rules! call {
($imm8:expr) => {
_mm256_shufflehi_epi16(a, $imm8)
};
}
let shuffle = constify_imm8_sae!(imm8, call);
static_assert_imm8!(IMM8);
let shuffle = _mm256_shufflehi_epi16(a, IMM8);
transmute(simd_select_bitmask(k, shuffle.as_i16x16(), src.as_i16x16()))
}
@ -16430,9 +16425,9 @@ mod tests {
#[simd_test(enable = "avx512bw,avx512vl")]
unsafe fn test_mm256_mask_shufflehi_epi16() {
let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
let r = _mm256_mask_shufflehi_epi16(a, 0, a, 0b00_01_01_11);
let r = _mm256_mask_shufflehi_epi16::<0b00_01_01_11>(a, 0, a);
assert_eq_m256i(r, a);
let r = _mm256_mask_shufflehi_epi16(a, 0b11111111_11111111, a, 0b00_01_01_11);
let r = _mm256_mask_shufflehi_epi16::<0b00_01_01_11>(a, 0b11111111_11111111, a);
let e = _mm256_set_epi16(3, 2, 2, 0, 4, 5, 6, 7, 11, 10, 10, 8, 12, 13, 14, 15);
assert_eq_m256i(r, e);
}