Skip to content

Commit cdb0a0e

Browse files
lqdAmanieu
authored andcommitted
convert _mm256_i64gather_pd to const generics
1 parent ffee2ff commit cdb0a0e

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
@@ -1774,20 +1774,19 @@ pub unsafe fn _mm_mask_i64gather_pd<const SCALE: i32>(
17741774
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_i64gather_pd)
17751775
#[inline]
17761776
#[target_feature(enable = "avx2")]
1777-
#[cfg_attr(test, assert_instr(vgatherqpd, scale = 1))]
1778-
#[rustc_args_required_const(2)]
1777+
#[cfg_attr(test, assert_instr(vgatherqpd, SCALE = 1))]
1778+
#[rustc_legacy_const_generics(2)]
17791779
#[stable(feature = "simd_x86", since = "1.27.0")]
1780-
pub unsafe fn _mm256_i64gather_pd(slice: *const f64, offsets: __m256i, scale: i32) -> __m256d {
1780+
pub unsafe fn _mm256_i64gather_pd<const SCALE: i32>(
1781+
slice: *const f64,
1782+
offsets: __m256i,
1783+
) -> __m256d {
1784+
static_assert_imm8_scale!(SCALE);
17811785
let zero = _mm256_setzero_pd();
17821786
let neg_one = _mm256_set1_pd(-1.0);
17831787
let slice = slice as *const i8;
17841788
let offsets = offsets.as_i64x4();
1785-
macro_rules! call {
1786-
($imm8:expr) => {
1787-
vpgatherqpd(zero, slice, offsets, neg_one, $imm8)
1788-
};
1789-
}
1790-
constify_imm8_gather!(scale, call)
1789+
vpgatherqpd(zero, slice, offsets, neg_one, SCALE as i8)
17911790
}
17921791

17931792
/// Returns values from `slice` at offsets determined by `offsets * scale`,
@@ -5905,7 +5904,7 @@ mod tests {
59055904
j += 1.0;
59065905
}
59075906
// A multiplier of 8 is word-addressing for f64s
5908-
let r = _mm256_i64gather_pd(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48), 8);
5907+
let r = _mm256_i64gather_pd::<8>(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48));
59095908
assert_eq_m256d(r, _mm256_setr_pd(0.0, 16.0, 32.0, 48.0));
59105909
}
59115910

0 commit comments

Comments
 (0)