Convert _mm256_insert_epi32 to const generics
This commit is contained in:
committed by
Amanieu d'Antras
parent
a1ef46850a
commit
e836a49019
@@ -1527,16 +1527,11 @@ pub unsafe fn _mm256_insert_epi16<const INDEX: i32>(a: __m256i, i: i16) -> __m25
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[target_feature(enable = "avx")]
|
#[target_feature(enable = "avx")]
|
||||||
// This intrinsic has no corresponding instruction.
|
// This intrinsic has no corresponding instruction.
|
||||||
#[rustc_args_required_const(2)]
|
#[rustc_legacy_const_generics(2)]
|
||||||
#[stable(feature = "simd_x86", since = "1.27.0")]
|
#[stable(feature = "simd_x86", since = "1.27.0")]
|
||||||
pub unsafe fn _mm256_insert_epi32(a: __m256i, i: i32, index: i32) -> __m256i {
|
pub unsafe fn _mm256_insert_epi32<const INDEX: i32>(a: __m256i, i: i32) -> __m256i {
|
||||||
let a = a.as_i32x8();
|
static_assert_imm3!(INDEX);
|
||||||
macro_rules! call {
|
transmute(simd_insert(a.as_i32x8(), INDEX as u32, i))
|
||||||
($index:expr) => {
|
|
||||||
simd_insert(a, $index, i)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
transmute(constify_imm3!(index, call))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads 256-bits (composed of 4 packed double-precision (64-bit)
|
/// Loads 256-bits (composed of 4 packed double-precision (64-bit)
|
||||||
@@ -3990,7 +3985,7 @@ mod tests {
|
|||||||
#[simd_test(enable = "avx")]
|
#[simd_test(enable = "avx")]
|
||||||
unsafe fn test_mm256_insert_epi32() {
|
unsafe fn test_mm256_insert_epi32() {
|
||||||
let a = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8);
|
let a = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8);
|
||||||
let r = _mm256_insert_epi32(a, 0, 7);
|
let r = _mm256_insert_epi32::<7>(a, 0);
|
||||||
let e = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 0);
|
let e = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 0);
|
||||||
assert_eq_m256i(r, e);
|
assert_eq_m256i(r, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4552,7 +4552,7 @@ mod tests {
|
|||||||
let b = _mm256_setr_epi32(7, 6, 2, 4, 3, 2, 1, 0);
|
let b = _mm256_setr_epi32(7, 6, 2, 4, 3, 2, 1, 0);
|
||||||
let r = _mm256_cmpeq_epi32(a, b);
|
let r = _mm256_cmpeq_epi32(a, b);
|
||||||
let e = _mm256_set1_epi32(0);
|
let e = _mm256_set1_epi32(0);
|
||||||
let e = _mm256_insert_epi32(e, !0, 2);
|
let e = _mm256_insert_epi32::<2>(e, !0);
|
||||||
assert_eq_m256i(r, e);
|
assert_eq_m256i(r, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4582,10 +4582,10 @@ mod tests {
|
|||||||
|
|
||||||
#[simd_test(enable = "avx2")]
|
#[simd_test(enable = "avx2")]
|
||||||
unsafe fn test_mm256_cmpgt_epi32() {
|
unsafe fn test_mm256_cmpgt_epi32() {
|
||||||
let a = _mm256_insert_epi32(_mm256_set1_epi32(0), 5, 0);
|
let a = _mm256_insert_epi32::<0>(_mm256_set1_epi32(0), 5);
|
||||||
let b = _mm256_set1_epi32(0);
|
let b = _mm256_set1_epi32(0);
|
||||||
let r = _mm256_cmpgt_epi32(a, b);
|
let r = _mm256_cmpgt_epi32(a, b);
|
||||||
assert_eq_m256i(r, _mm256_insert_epi32(_mm256_set1_epi32(0), !0, 0));
|
assert_eq_m256i(r, _mm256_insert_epi32::<0>(_mm256_set1_epi32(0), !0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[simd_test(enable = "avx2")]
|
#[simd_test(enable = "avx2")]
|
||||||
|
|||||||
Reference in New Issue
Block a user