Skip to content

Commit 51651b3

Browse files
lqdAmanieu
authored andcommitted
convert _mm_mask_i64gather_epi64 to const generics
1 parent c24058c commit 51651b3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

crates/core_arch/src/x86/avx2.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,26 +1658,21 @@ pub unsafe fn _mm_i64gather_epi64<const SCALE: i32>(
16581658
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_mask_i64gather_epi64)
16591659
#[inline]
16601660
#[target_feature(enable = "avx2")]
1661-
#[cfg_attr(test, assert_instr(vpgatherqq, scale = 1))]
1662-
#[rustc_args_required_const(4)]
1661+
#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1662+
#[rustc_legacy_const_generics(4)]
16631663
#[stable(feature = "simd_x86", since = "1.27.0")]
1664-
pub unsafe fn _mm_mask_i64gather_epi64(
1664+
pub unsafe fn _mm_mask_i64gather_epi64<const SCALE: i32>(
16651665
src: __m128i,
16661666
slice: *const i64,
16671667
offsets: __m128i,
16681668
mask: __m128i,
1669-
scale: i32,
16701669
) -> __m128i {
1670+
static_assert_imm8_scale!(SCALE);
16711671
let src = src.as_i64x2();
16721672
let mask = mask.as_i64x2();
16731673
let offsets = offsets.as_i64x2();
16741674
let slice = slice as *const i8;
1675-
macro_rules! call {
1676-
($imm8:expr) => {
1677-
pgatherqq(src, slice, offsets, mask, $imm8)
1678-
};
1679-
}
1680-
let r = constify_imm8_gather!(scale, call);
1675+
let r = pgatherqq(src, slice, offsets, mask, SCALE as i8);
16811676
transmute(r)
16821677
}
16831678

@@ -5849,12 +5844,11 @@ mod tests {
58495844
arr[i as usize] = i;
58505845
}
58515846
// A multiplier of 8 is word-addressing for i64s
5852-
let r = _mm_mask_i64gather_epi64(
5847+
let r = _mm_mask_i64gather_epi64::<8>(
58535848
_mm_set1_epi64x(256),
58545849
arr.as_ptr(),
58555850
_mm_setr_epi64x(16, 16),
58565851
_mm_setr_epi64x(-1, 0),
5857-
8,
58585852
);
58595853
assert_eq_m128i(r, _mm_setr_epi64x(16, 256));
58605854
}

0 commit comments

Comments
 (0)