Skip to content

Commit c24058c

Browse files
lqdAmanieu
authored andcommitted
convert _mm_i64gather_epi64 to const generics
1 parent 07ce359 commit c24058c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

crates/core_arch/src/x86/avx2.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,20 +1634,19 @@ pub unsafe fn _mm256_mask_i64gather_ps<const SCALE: i32>(
16341634
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_i64gather_epi64)
16351635
#[inline]
16361636
#[target_feature(enable = "avx2")]
1637-
#[cfg_attr(test, assert_instr(vpgatherqq, scale = 1))]
1638-
#[rustc_args_required_const(2)]
1637+
#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1638+
#[rustc_legacy_const_generics(2)]
16391639
#[stable(feature = "simd_x86", since = "1.27.0")]
1640-
pub unsafe fn _mm_i64gather_epi64(slice: *const i64, offsets: __m128i, scale: i32) -> __m128i {
1640+
pub unsafe fn _mm_i64gather_epi64<const SCALE: i32>(
1641+
slice: *const i64,
1642+
offsets: __m128i,
1643+
) -> __m128i {
1644+
static_assert_imm8_scale!(SCALE);
16411645
let zero = _mm_setzero_si128().as_i64x2();
16421646
let neg_one = _mm_set1_epi64x(-1).as_i64x2();
16431647
let slice = slice as *const i8;
16441648
let offsets = offsets.as_i64x2();
1645-
macro_rules! call {
1646-
($imm8:expr) => {
1647-
pgatherqq(zero, slice, offsets, neg_one, $imm8)
1648-
};
1649-
}
1650-
let r = constify_imm8_gather!(scale, call);
1649+
let r = pgatherqq(zero, slice, offsets, neg_one, SCALE as i8);
16511650
transmute(r)
16521651
}
16531652

@@ -5839,7 +5838,7 @@ mod tests {
58395838
arr[i as usize] = i;
58405839
}
58415840
// A multiplier of 8 is word-addressing for i64s
5842-
let r = _mm_i64gather_epi64(arr.as_ptr(), _mm_setr_epi64x(0, 16), 8);
5841+
let r = _mm_i64gather_epi64::<8>(arr.as_ptr(), _mm_setr_epi64x(0, 16));
58435842
assert_eq_m128i(r, _mm_setr_epi64x(0, 16));
58445843
}
58455844

0 commit comments

Comments
 (0)