Skip to content

Commit 704f584

Browse files
lqdAmanieu
authored andcommitted
convert _mm256_mask_i64gather_epi64 to const generics
1 parent bf612d8 commit 704f584

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
@@ -1707,26 +1707,21 @@ pub unsafe fn _mm256_i64gather_epi64<const SCALE: i32>(
17071707
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_mask_i64gather_epi64)
17081708
#[inline]
17091709
#[target_feature(enable = "avx2")]
1710-
#[cfg_attr(test, assert_instr(vpgatherqq, scale = 1))]
1711-
#[rustc_args_required_const(4)]
1710+
#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1711+
#[rustc_legacy_const_generics(4)]
17121712
#[stable(feature = "simd_x86", since = "1.27.0")]
1713-
pub unsafe fn _mm256_mask_i64gather_epi64(
1713+
pub unsafe fn _mm256_mask_i64gather_epi64<const SCALE: i32>(
17141714
src: __m256i,
17151715
slice: *const i64,
17161716
offsets: __m256i,
17171717
mask: __m256i,
1718-
scale: i32,
17191718
) -> __m256i {
1719+
static_assert_imm8_scale!(SCALE);
17201720
let src = src.as_i64x4();
17211721
let mask = mask.as_i64x4();
17221722
let offsets = offsets.as_i64x4();
17231723
let slice = slice as *const i8;
1724-
macro_rules! call {
1725-
($imm8:expr) => {
1726-
vpgatherqq(src, slice, offsets, mask, $imm8)
1727-
};
1728-
}
1729-
let r = constify_imm8_gather!(scale, call);
1724+
let r = vpgatherqq(src, slice, offsets, mask, SCALE as i8);
17301725
transmute(r)
17311726
}
17321727

@@ -5870,12 +5865,11 @@ mod tests {
58705865
arr[i as usize] = i;
58715866
}
58725867
// A multiplier of 8 is word-addressing for i64s
5873-
let r = _mm256_mask_i64gather_epi64(
5868+
let r = _mm256_mask_i64gather_epi64::<8>(
58745869
_mm256_set1_epi64x(256),
58755870
arr.as_ptr(),
58765871
_mm256_setr_epi64x(0, 16, 64, 96),
58775872
_mm256_setr_epi64x(-1, -1, -1, 0),
5878-
8,
58795873
);
58805874
assert_eq_m256i(r, _mm256_setr_epi64x(0, 16, 64, 256));
58815875
}

0 commit comments

Comments
 (0)