Skip to content

Commit b5461f8

Browse files
committed
Refactor avx512f: element extraction
1 parent caf4361 commit b5461f8

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-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: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25318,8 +25318,27 @@ 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+
pub unsafe fn _mm512_cvtss_f32(a: __m512) -> f32 {
25331+
simd_extract!(a, 0)
25332+
}
25333+
25334+
/// Copy the lower double-precision (64-bit) floating-point element of a to dst.
25335+
///
25336+
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm512_cvtsd_f64)
25337+
#[inline]
25338+
#[target_feature(enable = "avx512f")]
25339+
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
25340+
pub unsafe fn _mm512_cvtsd_f64(a: __m512d) -> f64 {
25341+
simd_extract!(a, 0)
2532325342
}
2532425343

2532525344
/// Broadcast the low packed 32-bit integer from a to all elements of dst.
@@ -58278,6 +58297,20 @@ mod tests {
5827858297
assert_eq!(r, e);
5827958298
}
5828058299

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

0 commit comments

Comments
 (0)