Skip to content

Commit 09ae5b9

Browse files
committed
Make sse3 functions const
1 parent 52fb781 commit 09ae5b9

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

crates/core_arch/src/x86/sse3.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use stdarch_test::assert_instr;
1414
#[target_feature(enable = "sse3")]
1515
#[cfg_attr(test, assert_instr(addsubps))]
1616
#[stable(feature = "simd_x86", since = "1.27.0")]
17-
pub fn _mm_addsub_ps(a: __m128, b: __m128) -> __m128 {
17+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
18+
pub const fn _mm_addsub_ps(a: __m128, b: __m128) -> __m128 {
1819
unsafe {
1920
let a = a.as_f32x4();
2021
let b = b.as_f32x4();
@@ -32,7 +33,8 @@ pub fn _mm_addsub_ps(a: __m128, b: __m128) -> __m128 {
3233
#[target_feature(enable = "sse3")]
3334
#[cfg_attr(test, assert_instr(addsubpd))]
3435
#[stable(feature = "simd_x86", since = "1.27.0")]
35-
pub fn _mm_addsub_pd(a: __m128d, b: __m128d) -> __m128d {
36+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
37+
pub const fn _mm_addsub_pd(a: __m128d, b: __m128d) -> __m128d {
3638
unsafe {
3739
let a = a.as_f64x2();
3840
let b = b.as_f64x2();
@@ -50,7 +52,8 @@ pub fn _mm_addsub_pd(a: __m128d, b: __m128d) -> __m128d {
5052
#[target_feature(enable = "sse3")]
5153
#[cfg_attr(test, assert_instr(haddpd))]
5254
#[stable(feature = "simd_x86", since = "1.27.0")]
53-
pub fn _mm_hadd_pd(a: __m128d, b: __m128d) -> __m128d {
55+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
56+
pub const fn _mm_hadd_pd(a: __m128d, b: __m128d) -> __m128d {
5457
unsafe {
5558
let even = simd_shuffle!(a, b, [0, 2]);
5659
let odd = simd_shuffle!(a, b, [1, 3]);
@@ -66,7 +69,8 @@ pub fn _mm_hadd_pd(a: __m128d, b: __m128d) -> __m128d {
6669
#[target_feature(enable = "sse3")]
6770
#[cfg_attr(test, assert_instr(haddps))]
6871
#[stable(feature = "simd_x86", since = "1.27.0")]
69-
pub fn _mm_hadd_ps(a: __m128, b: __m128) -> __m128 {
72+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
73+
pub const fn _mm_hadd_ps(a: __m128, b: __m128) -> __m128 {
7074
unsafe {
7175
let even = simd_shuffle!(a, b, [0, 2, 4, 6]);
7276
let odd = simd_shuffle!(a, b, [1, 3, 5, 7]);
@@ -82,7 +86,8 @@ pub fn _mm_hadd_ps(a: __m128, b: __m128) -> __m128 {
8286
#[target_feature(enable = "sse3")]
8387
#[cfg_attr(test, assert_instr(hsubpd))]
8488
#[stable(feature = "simd_x86", since = "1.27.0")]
85-
pub fn _mm_hsub_pd(a: __m128d, b: __m128d) -> __m128d {
89+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
90+
pub const fn _mm_hsub_pd(a: __m128d, b: __m128d) -> __m128d {
8691
unsafe {
8792
let even = simd_shuffle!(a, b, [0, 2]);
8893
let odd = simd_shuffle!(a, b, [1, 3]);
@@ -98,7 +103,8 @@ pub fn _mm_hsub_pd(a: __m128d, b: __m128d) -> __m128d {
98103
#[target_feature(enable = "sse3")]
99104
#[cfg_attr(test, assert_instr(hsubps))]
100105
#[stable(feature = "simd_x86", since = "1.27.0")]
101-
pub fn _mm_hsub_ps(a: __m128, b: __m128) -> __m128 {
106+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
107+
pub const fn _mm_hsub_ps(a: __m128, b: __m128) -> __m128 {
102108
unsafe {
103109
let even = simd_shuffle!(a, b, [0, 2, 4, 6]);
104110
let odd = simd_shuffle!(a, b, [1, 3, 5, 7]);
@@ -127,7 +133,8 @@ pub unsafe fn _mm_lddqu_si128(mem_addr: *const __m128i) -> __m128i {
127133
#[target_feature(enable = "sse3")]
128134
#[cfg_attr(test, assert_instr(movddup))]
129135
#[stable(feature = "simd_x86", since = "1.27.0")]
130-
pub fn _mm_movedup_pd(a: __m128d) -> __m128d {
136+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
137+
pub const fn _mm_movedup_pd(a: __m128d) -> __m128d {
131138
unsafe { simd_shuffle!(a, a, [0, 0]) }
132139
}
133140

@@ -139,7 +146,8 @@ pub fn _mm_movedup_pd(a: __m128d) -> __m128d {
139146
#[target_feature(enable = "sse3")]
140147
#[cfg_attr(test, assert_instr(movddup))]
141148
#[stable(feature = "simd_x86", since = "1.27.0")]
142-
pub unsafe fn _mm_loaddup_pd(mem_addr: *const f64) -> __m128d {
149+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
150+
pub const unsafe fn _mm_loaddup_pd(mem_addr: *const f64) -> __m128d {
143151
_mm_load1_pd(mem_addr)
144152
}
145153

@@ -151,7 +159,8 @@ pub unsafe fn _mm_loaddup_pd(mem_addr: *const f64) -> __m128d {
151159
#[target_feature(enable = "sse3")]
152160
#[cfg_attr(test, assert_instr(movshdup))]
153161
#[stable(feature = "simd_x86", since = "1.27.0")]
154-
pub fn _mm_movehdup_ps(a: __m128) -> __m128 {
162+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
163+
pub const fn _mm_movehdup_ps(a: __m128) -> __m128 {
155164
unsafe { simd_shuffle!(a, a, [1, 1, 3, 3]) }
156165
}
157166

@@ -163,7 +172,8 @@ pub fn _mm_movehdup_ps(a: __m128) -> __m128 {
163172
#[target_feature(enable = "sse3")]
164173
#[cfg_attr(test, assert_instr(movsldup))]
165174
#[stable(feature = "simd_x86", since = "1.27.0")]
166-
pub fn _mm_moveldup_ps(a: __m128) -> __m128 {
175+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
176+
pub const fn _mm_moveldup_ps(a: __m128) -> __m128 {
167177
unsafe { simd_shuffle!(a, a, [0, 0, 2, 2]) }
168178
}
169179

0 commit comments

Comments
 (0)