Skip to content

Commit 93f1c45

Browse files
committed
use simd_splat for the set1 functions
1 parent a95c071 commit 93f1c45

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

crates/core_arch/src/x86/avx.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,7 +2746,7 @@ pub const fn _mm256_setr_epi64x(a: i64, b: i64, c: i64, d: i64) -> __m256i {
27462746
#[stable(feature = "simd_x86", since = "1.27.0")]
27472747
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
27482748
pub const fn _mm256_set1_pd(a: f64) -> __m256d {
2749-
_mm256_setr_pd(a, a, a, a)
2749+
f64x4::splat(a).as_m256d()
27502750
}
27512751

27522752
/// Broadcasts single-precision (32-bit) floating-point value `a` to all
@@ -2759,7 +2759,7 @@ pub const fn _mm256_set1_pd(a: f64) -> __m256d {
27592759
#[stable(feature = "simd_x86", since = "1.27.0")]
27602760
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
27612761
pub const fn _mm256_set1_ps(a: f32) -> __m256 {
2762-
_mm256_setr_ps(a, a, a, a, a, a, a, a)
2762+
f32x8::splat(a).as_m256()
27632763
}
27642764

27652765
/// Broadcasts 8-bit integer `a` to all elements of returned vector.
@@ -2772,13 +2772,7 @@ pub const fn _mm256_set1_ps(a: f32) -> __m256 {
27722772
#[stable(feature = "simd_x86", since = "1.27.0")]
27732773
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
27742774
pub const fn _mm256_set1_epi8(a: i8) -> __m256i {
2775-
#[rustfmt::skip]
2776-
_mm256_setr_epi8(
2777-
a, a, a, a, a, a, a, a,
2778-
a, a, a, a, a, a, a, a,
2779-
a, a, a, a, a, a, a, a,
2780-
a, a, a, a, a, a, a, a,
2781-
)
2775+
i8x32::splat(a).as_m256i()
27822776
}
27832777

27842778
/// Broadcasts 16-bit integer `a` to all elements of returned vector.
@@ -2793,7 +2787,7 @@ pub const fn _mm256_set1_epi8(a: i8) -> __m256i {
27932787
#[stable(feature = "simd_x86", since = "1.27.0")]
27942788
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
27952789
pub const fn _mm256_set1_epi16(a: i16) -> __m256i {
2796-
_mm256_setr_epi16(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a)
2790+
i16x16::splat(a).as_m256i()
27972791
}
27982792

27992793
/// Broadcasts 32-bit integer `a` to all elements of returned vector.
@@ -2806,7 +2800,7 @@ pub const fn _mm256_set1_epi16(a: i16) -> __m256i {
28062800
#[stable(feature = "simd_x86", since = "1.27.0")]
28072801
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
28082802
pub const fn _mm256_set1_epi32(a: i32) -> __m256i {
2809-
_mm256_setr_epi32(a, a, a, a, a, a, a, a)
2803+
i32x8::splat(a).as_m256i()
28102804
}
28112805

28122806
/// Broadcasts 64-bit integer `a` to all elements of returned vector.
@@ -2821,7 +2815,7 @@ pub const fn _mm256_set1_epi32(a: i32) -> __m256i {
28212815
#[stable(feature = "simd_x86", since = "1.27.0")]
28222816
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
28232817
pub const fn _mm256_set1_epi64x(a: i64) -> __m256i {
2824-
_mm256_setr_epi64x(a, a, a, a)
2818+
i64x4::splat(a).as_m256i()
28252819
}
28262820

28272821
/// Cast vector of type __m256d to type __m256.

crates/core_arch/src/x86/sse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ pub const fn _mm_set_ss(a: f32) -> __m128 {
932932
#[stable(feature = "simd_x86", since = "1.27.0")]
933933
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
934934
pub const fn _mm_set1_ps(a: f32) -> __m128 {
935-
__m128([a, a, a, a])
935+
f32x4::splat(a).as_m128()
936936
}
937937

938938
/// Alias for [`_mm_set1_ps`](fn._mm_set1_ps.html)

crates/core_arch/src/x86/sse2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ pub const fn _mm_set_epi8(
11761176
#[stable(feature = "simd_x86", since = "1.27.0")]
11771177
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
11781178
pub const fn _mm_set1_epi64x(a: i64) -> __m128i {
1179-
_mm_set_epi64x(a, a)
1179+
i64x2::splat(a).as_m128i()
11801180
}
11811181

11821182
/// Broadcasts 32-bit integer `a` to all elements.
@@ -1188,7 +1188,7 @@ pub const fn _mm_set1_epi64x(a: i64) -> __m128i {
11881188
#[stable(feature = "simd_x86", since = "1.27.0")]
11891189
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
11901190
pub const fn _mm_set1_epi32(a: i32) -> __m128i {
1191-
_mm_set_epi32(a, a, a, a)
1191+
i32x4::splat(a).as_m128i()
11921192
}
11931193

11941194
/// Broadcasts 16-bit integer `a` to all elements.
@@ -1200,7 +1200,7 @@ pub const fn _mm_set1_epi32(a: i32) -> __m128i {
12001200
#[stable(feature = "simd_x86", since = "1.27.0")]
12011201
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
12021202
pub const fn _mm_set1_epi16(a: i16) -> __m128i {
1203-
_mm_set_epi16(a, a, a, a, a, a, a, a)
1203+
i16x8::splat(a).as_m128i()
12041204
}
12051205

12061206
/// Broadcasts 8-bit integer `a` to all elements.
@@ -1212,7 +1212,7 @@ pub const fn _mm_set1_epi16(a: i16) -> __m128i {
12121212
#[stable(feature = "simd_x86", since = "1.27.0")]
12131213
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
12141214
pub const fn _mm_set1_epi8(a: i8) -> __m128i {
1215-
_mm_set_epi8(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a)
1215+
i8x16::splat(a).as_m128i()
12161216
}
12171217

12181218
/// Sets packed 32-bit integers with the supplied values in reverse order.

0 commit comments

Comments
 (0)