Skip to content

Commit 9b58d00

Browse files
lqdAmanieu
authored andcommitted
convert _mm256_i64gather_ps to const generics
1 parent 3a4ef5f commit 9b58d00

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

crates/core_arch/src/x86/avx2.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,20 +1592,16 @@ pub unsafe fn _mm_mask_i64gather_ps<const SCALE: i32>(
15921592
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_i64gather_ps)
15931593
#[inline]
15941594
#[target_feature(enable = "avx2")]
1595-
#[cfg_attr(test, assert_instr(vgatherqps, scale = 1))]
1596-
#[rustc_args_required_const(2)]
1595+
#[cfg_attr(test, assert_instr(vgatherqps, SCALE = 1))]
1596+
#[rustc_legacy_const_generics(2)]
15971597
#[stable(feature = "simd_x86", since = "1.27.0")]
1598-
pub unsafe fn _mm256_i64gather_ps(slice: *const f32, offsets: __m256i, scale: i32) -> __m128 {
1598+
pub unsafe fn _mm256_i64gather_ps<const SCALE: i32>(slice: *const f32, offsets: __m256i) -> __m128 {
1599+
static_assert_imm8_scale!(SCALE);
15991600
let zero = _mm_setzero_ps();
16001601
let neg_one = _mm_set1_ps(-1.0);
16011602
let offsets = offsets.as_i64x4();
16021603
let slice = slice as *const i8;
1603-
macro_rules! call {
1604-
($imm8:expr) => {
1605-
vpgatherqps(zero, slice, offsets, neg_one, $imm8)
1606-
};
1607-
}
1608-
constify_imm8_gather!(scale, call)
1604+
vpgatherqps(zero, slice, offsets, neg_one, SCALE as i8)
16091605
}
16101606

16111607
/// Returns values from `slice` at offsets determined by `offsets * scale`,
@@ -5819,7 +5815,7 @@ mod tests {
58195815
j += 1.0;
58205816
}
58215817
// A multiplier of 4 is word-addressing for f32s
5822-
let r = _mm256_i64gather_ps(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48), 4);
5818+
let r = _mm256_i64gather_ps::<4>(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48));
58235819
assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 32.0, 48.0));
58245820
}
58255821

0 commit comments

Comments
 (0)