convert _mm_i32gather_epi64 to const generics

This commit is contained in:
Rémy Rakic 2021-03-06 00:50:39 +01:00 committed by Amanieu d'Antras
parent 22c691f703
commit a1ced34d15

View file

@ -1267,20 +1267,19 @@ pub unsafe fn _mm256_mask_i32gather_ps<const SCALE: i32>(
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_i32gather_epi64)
#[inline]
#[target_feature(enable = "avx2")]
#[cfg_attr(test, assert_instr(vpgatherdq, scale = 1))]
#[rustc_args_required_const(2)]
#[cfg_attr(test, assert_instr(vpgatherdq, SCALE = 1))]
#[rustc_legacy_const_generics(2)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_i32gather_epi64(slice: *const i64, offsets: __m128i, scale: i32) -> __m128i {
pub unsafe fn _mm_i32gather_epi64<const SCALE: i32>(
slice: *const i64,
offsets: __m128i,
) -> __m128i {
static_assert_imm8_scale!(SCALE);
let zero = _mm_setzero_si128().as_i64x2();
let neg_one = _mm_set1_epi64x(-1).as_i64x2();
let offsets = offsets.as_i32x4();
let slice = slice as *const i8;
macro_rules! call {
($imm8:expr) => {
pgatherdq(zero, slice, offsets, neg_one, $imm8)
};
}
let r = constify_imm8_gather!(scale, call);
let r = pgatherdq(zero, slice, offsets, neg_one, SCALE as i8);
transmute(r)
}
@ -5664,7 +5663,7 @@ mod tests {
arr[i as usize] = i;
}
// A multiplier of 8 is word-addressing for i64s
let r = _mm_i32gather_epi64(arr.as_ptr(), _mm_setr_epi32(0, 16, 0, 0), 8);
let r = _mm_i32gather_epi64::<8>(arr.as_ptr(), _mm_setr_epi32(0, 16, 0, 0));
assert_eq_m128i(r, _mm_setr_epi64x(0, 16));
}