Skip to content

Commit aaeb961

Browse files
committed
Refactor avx512f: element extraction
1 parent c719672 commit aaeb961

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

crates/core_arch/missing-x86.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@
157157
* [ ] [`_kshiftli_mask16`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_kshiftli_mask16)
158158
* [ ] [`_kshiftri_mask16`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_kshiftri_mask16)
159159
* [ ] [`_load_mask16`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_load_mask16)
160-
* [ ] [`_mm512_cvtsd_f64`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm512_cvtsd_f64)
161-
* [ ] [`_mm512_cvtss_f32`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm512_cvtss_f32)
162160
* [ ] [`_mm512_i32logather_epi64`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm512_i32logather_epi64)
163161
* [ ] [`_mm512_i32logather_pd`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm512_i32logather_pd)
164162
* [ ] [`_mm512_i32loscatter_epi64`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm512_i32loscatter_epi64)

crates/core_arch/src/x86/avx512f.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25318,8 +25318,29 @@ pub unsafe fn _mm512_castsi512_pd(a: __m512i) -> __m512d {
2531825318
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
2531925319
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(vmovd))]
2532025320
pub unsafe fn _mm512_cvtsi512_si32(a: __m512i) -> i32 {
25321-
let extract: i32 = simd_extract!(a.as_i32x16(), 0);
25322-
extract
25321+
simd_extract!(a.as_i32x16(), 0)
25322+
}
25323+
25324+
/// Copy the lower single-precision (32-bit) floating-point element of a to dst.
25325+
///
25326+
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm512_cvtss_f32)
25327+
#[inline]
25328+
#[target_feature(enable = "avx512f")]
25329+
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
25330+
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(vmovd))]
25331+
pub unsafe fn _mm512_cvtss_f32(a: __m512) -> f32 {
25332+
simd_extract!(a, 0)
25333+
}
25334+
25335+
/// Copy the lower double-precision (64-bit) floating-point element of a to dst.
25336+
///
25337+
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm512_cvtsd_f64)
25338+
#[inline]
25339+
#[target_feature(enable = "avx512f")]
25340+
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
25341+
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(vmovd))]
25342+
pub unsafe fn _mm512_cvtsd_f64(a: __m512d) -> f64 {
25343+
simd_extract!(a, 0)
2532325344
}
2532425345

2532525346
/// Broadcast the low packed 32-bit integer from a to all elements of dst.
@@ -58278,6 +58299,22 @@ mod tests {
5827858299
assert_eq!(r, e);
5827958300
}
5828058301

58302+
#[simd_test(enable = "avx512f")]
58303+
unsafe fn test_mm512_cvtss_f32() {
58304+
let a = _mm512_setr_ps(
58305+
312.0134, 3., 2., 5., 8., 9., 64., 50., -4., -3., -2., -5., -8., -9., -64., -50.,
58306+
);
58307+
assert_eq!(_mm512_cvtss_f32(a), 312.0134);
58308+
}
58309+
58310+
#[simd_test(enable = "avx512f")]
58311+
unsafe fn test_mm512_cvtsd_f64() {
58312+
let r = _mm612_cvtsd_f64(_mm512_setr_pd(
58313+
-1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8,
58314+
));
58315+
assert_eq!(r, -1.1);
58316+
}
58317+
5828158318
#[simd_test(enable = "avx512f")]
5828258319
unsafe fn test_mm512_shuffle_pd() {
5828358320
let a = _mm512_setr_pd(1., 4., 5., 8., 1., 4., 5., 8.);

0 commit comments

Comments
 (0)