Skip to content

Commit 2e9c888

Browse files
committed
Make fma functions const
1 parent f722ccb commit 2e9c888

File tree

1 file changed

+64
-32
lines changed
  • crates/core_arch/src/x86

1 file changed

+64
-32
lines changed

crates/core_arch/src/x86/fma.rs

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use stdarch_test::assert_instr;
3333
#[target_feature(enable = "fma")]
3434
#[cfg_attr(test, assert_instr(vfmadd))]
3535
#[stable(feature = "simd_x86", since = "1.27.0")]
36-
pub fn _mm_fmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
36+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
37+
pub const fn _mm_fmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
3738
unsafe { simd_fma(a, b, c) }
3839
}
3940

@@ -45,7 +46,8 @@ pub fn _mm_fmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
4546
#[target_feature(enable = "fma")]
4647
#[cfg_attr(test, assert_instr(vfmadd))]
4748
#[stable(feature = "simd_x86", since = "1.27.0")]
48-
pub fn _mm256_fmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
49+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
50+
pub const fn _mm256_fmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
4951
unsafe { simd_fma(a, b, c) }
5052
}
5153

@@ -57,7 +59,8 @@ pub fn _mm256_fmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
5759
#[target_feature(enable = "fma")]
5860
#[cfg_attr(test, assert_instr(vfmadd))]
5961
#[stable(feature = "simd_x86", since = "1.27.0")]
60-
pub fn _mm_fmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
62+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
63+
pub const fn _mm_fmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
6164
unsafe { simd_fma(a, b, c) }
6265
}
6366

@@ -69,7 +72,8 @@ pub fn _mm_fmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
6972
#[target_feature(enable = "fma")]
7073
#[cfg_attr(test, assert_instr(vfmadd))]
7174
#[stable(feature = "simd_x86", since = "1.27.0")]
72-
pub fn _mm256_fmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
75+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
76+
pub const fn _mm256_fmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
7377
unsafe { simd_fma(a, b, c) }
7478
}
7579

@@ -83,7 +87,8 @@ pub fn _mm256_fmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
8387
#[target_feature(enable = "fma")]
8488
#[cfg_attr(test, assert_instr(vfmadd))]
8589
#[stable(feature = "simd_x86", since = "1.27.0")]
86-
pub fn _mm_fmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
90+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
91+
pub const fn _mm_fmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
8792
unsafe {
8893
simd_insert!(
8994
a,
@@ -103,7 +108,8 @@ pub fn _mm_fmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
103108
#[target_feature(enable = "fma")]
104109
#[cfg_attr(test, assert_instr(vfmadd))]
105110
#[stable(feature = "simd_x86", since = "1.27.0")]
106-
pub fn _mm_fmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
111+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
112+
pub const fn _mm_fmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
107113
unsafe {
108114
simd_insert!(
109115
a,
@@ -122,7 +128,8 @@ pub fn _mm_fmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
122128
#[target_feature(enable = "fma")]
123129
#[cfg_attr(test, assert_instr(vfmaddsub))]
124130
#[stable(feature = "simd_x86", since = "1.27.0")]
125-
pub fn _mm_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
131+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
132+
pub const fn _mm_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
126133
unsafe {
127134
let add = simd_fma(a, b, c);
128135
let sub = simd_fma(a, b, simd_neg(c));
@@ -139,7 +146,8 @@ pub fn _mm_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
139146
#[target_feature(enable = "fma")]
140147
#[cfg_attr(test, assert_instr(vfmaddsub))]
141148
#[stable(feature = "simd_x86", since = "1.27.0")]
142-
pub fn _mm256_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
149+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
150+
pub const fn _mm256_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
143151
unsafe {
144152
let add = simd_fma(a, b, c);
145153
let sub = simd_fma(a, b, simd_neg(c));
@@ -156,7 +164,8 @@ pub fn _mm256_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
156164
#[target_feature(enable = "fma")]
157165
#[cfg_attr(test, assert_instr(vfmaddsub))]
158166
#[stable(feature = "simd_x86", since = "1.27.0")]
159-
pub fn _mm_fmaddsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
167+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
168+
pub const fn _mm_fmaddsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
160169
unsafe {
161170
let add = simd_fma(a, b, c);
162171
let sub = simd_fma(a, b, simd_neg(c));
@@ -173,7 +182,8 @@ pub fn _mm_fmaddsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
173182
#[target_feature(enable = "fma")]
174183
#[cfg_attr(test, assert_instr(vfmaddsub))]
175184
#[stable(feature = "simd_x86", since = "1.27.0")]
176-
pub fn _mm256_fmaddsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
185+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
186+
pub const fn _mm256_fmaddsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
177187
unsafe {
178188
let add = simd_fma(a, b, c);
179189
let sub = simd_fma(a, b, simd_neg(c));
@@ -189,7 +199,8 @@ pub fn _mm256_fmaddsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
189199
#[target_feature(enable = "fma")]
190200
#[cfg_attr(test, assert_instr(vfmsub))]
191201
#[stable(feature = "simd_x86", since = "1.27.0")]
192-
pub fn _mm_fmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
202+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
203+
pub const fn _mm_fmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
193204
unsafe { simd_fma(a, b, simd_neg(c)) }
194205
}
195206

@@ -201,7 +212,8 @@ pub fn _mm_fmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
201212
#[target_feature(enable = "fma")]
202213
#[cfg_attr(test, assert_instr(vfmsub))]
203214
#[stable(feature = "simd_x86", since = "1.27.0")]
204-
pub fn _mm256_fmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
215+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
216+
pub const fn _mm256_fmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
205217
unsafe { simd_fma(a, b, simd_neg(c)) }
206218
}
207219

@@ -213,7 +225,8 @@ pub fn _mm256_fmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
213225
#[target_feature(enable = "fma")]
214226
#[cfg_attr(test, assert_instr(vfmsub213ps))]
215227
#[stable(feature = "simd_x86", since = "1.27.0")]
216-
pub fn _mm_fmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
228+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
229+
pub const fn _mm_fmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
217230
unsafe { simd_fma(a, b, simd_neg(c)) }
218231
}
219232

@@ -225,7 +238,8 @@ pub fn _mm_fmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
225238
#[target_feature(enable = "fma")]
226239
#[cfg_attr(test, assert_instr(vfmsub213ps))]
227240
#[stable(feature = "simd_x86", since = "1.27.0")]
228-
pub fn _mm256_fmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
241+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
242+
pub const fn _mm256_fmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
229243
unsafe { simd_fma(a, b, simd_neg(c)) }
230244
}
231245

@@ -239,7 +253,8 @@ pub fn _mm256_fmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
239253
#[target_feature(enable = "fma")]
240254
#[cfg_attr(test, assert_instr(vfmsub))]
241255
#[stable(feature = "simd_x86", since = "1.27.0")]
242-
pub fn _mm_fmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
256+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
257+
pub const fn _mm_fmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
243258
unsafe {
244259
simd_insert!(
245260
a,
@@ -259,7 +274,8 @@ pub fn _mm_fmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
259274
#[target_feature(enable = "fma")]
260275
#[cfg_attr(test, assert_instr(vfmsub))]
261276
#[stable(feature = "simd_x86", since = "1.27.0")]
262-
pub fn _mm_fmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
277+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
278+
pub const fn _mm_fmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
263279
unsafe {
264280
simd_insert!(
265281
a,
@@ -278,7 +294,8 @@ pub fn _mm_fmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
278294
#[target_feature(enable = "fma")]
279295
#[cfg_attr(test, assert_instr(vfmsubadd))]
280296
#[stable(feature = "simd_x86", since = "1.27.0")]
281-
pub fn _mm_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
297+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
298+
pub const fn _mm_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
282299
unsafe {
283300
let add = simd_fma(a, b, c);
284301
let sub = simd_fma(a, b, simd_neg(c));
@@ -295,7 +312,8 @@ pub fn _mm_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
295312
#[target_feature(enable = "fma")]
296313
#[cfg_attr(test, assert_instr(vfmsubadd))]
297314
#[stable(feature = "simd_x86", since = "1.27.0")]
298-
pub fn _mm256_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
315+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
316+
pub const fn _mm256_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
299317
unsafe {
300318
let add = simd_fma(a, b, c);
301319
let sub = simd_fma(a, b, simd_neg(c));
@@ -312,7 +330,8 @@ pub fn _mm256_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
312330
#[target_feature(enable = "fma")]
313331
#[cfg_attr(test, assert_instr(vfmsubadd))]
314332
#[stable(feature = "simd_x86", since = "1.27.0")]
315-
pub fn _mm_fmsubadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
333+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
334+
pub const fn _mm_fmsubadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
316335
unsafe {
317336
let add = simd_fma(a, b, c);
318337
let sub = simd_fma(a, b, simd_neg(c));
@@ -329,7 +348,8 @@ pub fn _mm_fmsubadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
329348
#[target_feature(enable = "fma")]
330349
#[cfg_attr(test, assert_instr(vfmsubadd))]
331350
#[stable(feature = "simd_x86", since = "1.27.0")]
332-
pub fn _mm256_fmsubadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
351+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
352+
pub const fn _mm256_fmsubadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
333353
unsafe {
334354
let add = simd_fma(a, b, c);
335355
let sub = simd_fma(a, b, simd_neg(c));
@@ -345,7 +365,8 @@ pub fn _mm256_fmsubadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
345365
#[target_feature(enable = "fma")]
346366
#[cfg_attr(test, assert_instr(vfnmadd))]
347367
#[stable(feature = "simd_x86", since = "1.27.0")]
348-
pub fn _mm_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
368+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
369+
pub const fn _mm_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
349370
unsafe { simd_fma(simd_neg(a), b, c) }
350371
}
351372

@@ -357,7 +378,8 @@ pub fn _mm_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
357378
#[target_feature(enable = "fma")]
358379
#[cfg_attr(test, assert_instr(vfnmadd))]
359380
#[stable(feature = "simd_x86", since = "1.27.0")]
360-
pub fn _mm256_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
381+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
382+
pub const fn _mm256_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
361383
unsafe { simd_fma(simd_neg(a), b, c) }
362384
}
363385

@@ -369,7 +391,8 @@ pub fn _mm256_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
369391
#[target_feature(enable = "fma")]
370392
#[cfg_attr(test, assert_instr(vfnmadd))]
371393
#[stable(feature = "simd_x86", since = "1.27.0")]
372-
pub fn _mm_fnmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
394+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
395+
pub const fn _mm_fnmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
373396
unsafe { simd_fma(simd_neg(a), b, c) }
374397
}
375398

@@ -381,7 +404,8 @@ pub fn _mm_fnmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
381404
#[target_feature(enable = "fma")]
382405
#[cfg_attr(test, assert_instr(vfnmadd))]
383406
#[stable(feature = "simd_x86", since = "1.27.0")]
384-
pub fn _mm256_fnmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
407+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
408+
pub const fn _mm256_fnmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
385409
unsafe { simd_fma(simd_neg(a), b, c) }
386410
}
387411

@@ -395,7 +419,8 @@ pub fn _mm256_fnmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
395419
#[target_feature(enable = "fma")]
396420
#[cfg_attr(test, assert_instr(vfnmadd))]
397421
#[stable(feature = "simd_x86", since = "1.27.0")]
398-
pub fn _mm_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
422+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
423+
pub const fn _mm_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
399424
unsafe {
400425
simd_insert!(
401426
a,
@@ -415,7 +440,8 @@ pub fn _mm_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
415440
#[target_feature(enable = "fma")]
416441
#[cfg_attr(test, assert_instr(vfnmadd))]
417442
#[stable(feature = "simd_x86", since = "1.27.0")]
418-
pub fn _mm_fnmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
443+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
444+
pub const fn _mm_fnmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
419445
unsafe {
420446
simd_insert!(
421447
a,
@@ -434,7 +460,8 @@ pub fn _mm_fnmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
434460
#[target_feature(enable = "fma")]
435461
#[cfg_attr(test, assert_instr(vfnmsub))]
436462
#[stable(feature = "simd_x86", since = "1.27.0")]
437-
pub fn _mm_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
463+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
464+
pub const fn _mm_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
438465
unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) }
439466
}
440467

@@ -447,7 +474,8 @@ pub fn _mm_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
447474
#[target_feature(enable = "fma")]
448475
#[cfg_attr(test, assert_instr(vfnmsub))]
449476
#[stable(feature = "simd_x86", since = "1.27.0")]
450-
pub fn _mm256_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
477+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
478+
pub const fn _mm256_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
451479
unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) }
452480
}
453481

@@ -460,7 +488,8 @@ pub fn _mm256_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
460488
#[target_feature(enable = "fma")]
461489
#[cfg_attr(test, assert_instr(vfnmsub))]
462490
#[stable(feature = "simd_x86", since = "1.27.0")]
463-
pub fn _mm_fnmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
491+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
492+
pub const fn _mm_fnmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
464493
unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) }
465494
}
466495

@@ -473,7 +502,8 @@ pub fn _mm_fnmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 {
473502
#[target_feature(enable = "fma")]
474503
#[cfg_attr(test, assert_instr(vfnmsub))]
475504
#[stable(feature = "simd_x86", since = "1.27.0")]
476-
pub fn _mm256_fnmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
505+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
506+
pub const fn _mm256_fnmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
477507
unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) }
478508
}
479509

@@ -488,7 +518,8 @@ pub fn _mm256_fnmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
488518
#[target_feature(enable = "fma")]
489519
#[cfg_attr(test, assert_instr(vfnmsub))]
490520
#[stable(feature = "simd_x86", since = "1.27.0")]
491-
pub fn _mm_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
521+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
522+
pub const fn _mm_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
492523
unsafe {
493524
simd_insert!(
494525
a,
@@ -509,7 +540,8 @@ pub fn _mm_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d {
509540
#[target_feature(enable = "fma")]
510541
#[cfg_attr(test, assert_instr(vfnmsub))]
511542
#[stable(feature = "simd_x86", since = "1.27.0")]
512-
pub fn _mm_fnmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
543+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
544+
pub const fn _mm_fnmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 {
513545
unsafe {
514546
simd_insert!(
515547
a,

0 commit comments

Comments
 (0)