Skip to content

Commit 07ce359

Browse files
lqdAmanieu
authored andcommitted
convert _mm256_mask_i64gather_ps to const generics
1 parent 9b58d00 commit 07ce359

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
@@ -1612,24 +1612,19 @@ pub unsafe fn _mm256_i64gather_ps<const SCALE: i32>(slice: *const f32, offsets:
16121612
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_mask_i64gather_ps)
16131613
#[inline]
16141614
#[target_feature(enable = "avx2")]
1615-
#[cfg_attr(test, assert_instr(vgatherqps, scale = 1))]
1616-
#[rustc_args_required_const(4)]
1615+
#[cfg_attr(test, assert_instr(vgatherqps, SCALE = 1))]
1616+
#[rustc_legacy_const_generics(4)]
16171617
#[stable(feature = "simd_x86", since = "1.27.0")]
1618-
pub unsafe fn _mm256_mask_i64gather_ps(
1618+
pub unsafe fn _mm256_mask_i64gather_ps<const SCALE: i32>(
16191619
src: __m128,
16201620
slice: *const f32,
16211621
offsets: __m256i,
16221622
mask: __m128,
1623-
scale: i32,
16241623
) -> __m128 {
1624+
static_assert_imm8_scale!(SCALE);
16251625
let offsets = offsets.as_i64x4();
16261626
let slice = slice as *const i8;
1627-
macro_rules! call {
1628-
($imm8:expr) => {
1629-
vpgatherqps(src, slice, offsets, mask, $imm8)
1630-
};
1631-
}
1632-
constify_imm8_gather!(scale, call)
1627+
vpgatherqps(src, slice, offsets, mask, SCALE as i8)
16331628
}
16341629

16351630
/// Returns values from `slice` at offsets determined by `offsets * scale`,
@@ -5828,12 +5823,11 @@ mod tests {
58285823
j += 1.0;
58295824
}
58305825
// A multiplier of 4 is word-addressing for f32s
5831-
let r = _mm256_mask_i64gather_ps(
5826+
let r = _mm256_mask_i64gather_ps::<4>(
58325827
_mm_set1_ps(256.0),
58335828
arr.as_ptr(),
58345829
_mm256_setr_epi64x(0, 16, 64, 96),
58355830
_mm_setr_ps(-1.0, -1.0, -1.0, 0.0),
5836-
4,
58375831
);
58385832
assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 64.0, 256.0));
58395833
}

0 commit comments

Comments
 (0)