convert _mm_i32gather_ps to const generics

This commit is contained in:
Rémy Rakic 2021-03-06 00:42:15 +01:00 committed by Amanieu d'Antras
parent d69a908608
commit c84824156b

View file

@ -1183,20 +1183,16 @@ pub unsafe fn _mm256_mask_i32gather_epi32<const SCALE: i32>(
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_i32gather_ps)
#[inline]
#[target_feature(enable = "avx2")]
#[cfg_attr(test, assert_instr(vgatherdps, scale = 1))]
#[rustc_args_required_const(2)]
#[cfg_attr(test, assert_instr(vgatherdps, SCALE = 1))]
#[rustc_legacy_const_generics(2)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_i32gather_ps(slice: *const f32, offsets: __m128i, scale: i32) -> __m128 {
pub unsafe fn _mm_i32gather_ps<const SCALE: i32>(slice: *const f32, offsets: __m128i) -> __m128 {
static_assert_imm8_scale!(SCALE);
let zero = _mm_setzero_ps();
let neg_one = _mm_set1_ps(-1.0);
let offsets = offsets.as_i32x4();
let slice = slice as *const i8;
macro_rules! call {
($imm8:expr) => {
pgatherdps(zero, slice, offsets, neg_one, $imm8)
};
}
constify_imm8_gather!(scale, call)
pgatherdps(zero, slice, offsets, neg_one, SCALE as i8)
}
/// Returns values from `slice` at offsets determined by `offsets * scale`,
@ -5618,7 +5614,7 @@ mod tests {
j += 1.0;
}
// A multiplier of 4 is word-addressing for f32s
let r = _mm_i32gather_ps(arr.as_ptr(), _mm_setr_epi32(0, 16, 32, 48), 4);
let r = _mm_i32gather_ps::<4>(arr.as_ptr(), _mm_setr_epi32(0, 16, 32, 48));
assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 32.0, 48.0));
}