Skip to content

Commit bf612d8

Browse files
lqdAmanieu
authored andcommitted
convert _mm256_i64gather_epi64 to const generics
1 parent 51651b3 commit bf612d8

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
@@ -1683,20 +1683,19 @@ pub unsafe fn _mm_mask_i64gather_epi64<const SCALE: i32>(
16831683
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_i64gather_epi64)
16841684
#[inline]
16851685
#[target_feature(enable = "avx2")]
1686-
#[cfg_attr(test, assert_instr(vpgatherqq, scale = 1))]
1687-
#[rustc_args_required_const(2)]
1686+
#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1687+
#[rustc_legacy_const_generics(2)]
16881688
#[stable(feature = "simd_x86", since = "1.27.0")]
1689-
pub unsafe fn _mm256_i64gather_epi64(slice: *const i64, offsets: __m256i, scale: i32) -> __m256i {
1689+
pub unsafe fn _mm256_i64gather_epi64<const SCALE: i32>(
1690+
slice: *const i64,
1691+
offsets: __m256i,
1692+
) -> __m256i {
1693+
static_assert_imm8_scale!(SCALE);
16901694
let zero = _mm256_setzero_si256().as_i64x4();
16911695
let neg_one = _mm256_set1_epi64x(-1).as_i64x4();
16921696
let slice = slice as *const i8;
16931697
let offsets = offsets.as_i64x4();
1694-
macro_rules! call {
1695-
($imm8:expr) => {
1696-
vpgatherqq(zero, slice, offsets, neg_one, $imm8)
1697-
};
1698-
}
1699-
let r = constify_imm8_gather!(scale, call);
1698+
let r = vpgatherqq(zero, slice, offsets, neg_one, SCALE as i8);
17001699
transmute(r)
17011700
}
17021701

@@ -5860,7 +5859,7 @@ mod tests {
58605859
arr[i as usize] = i;
58615860
}
58625861
// A multiplier of 8 is word-addressing for i64s
5863-
let r = _mm256_i64gather_epi64(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48), 8);
5862+
let r = _mm256_i64gather_epi64::<8>(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48));
58645863
assert_eq_m256i(r, _mm256_setr_epi64x(0, 16, 32, 48));
58655864
}
58665865

0 commit comments

Comments
 (0)