Skip to content

Commit 10f65e4

Browse files
committed
Refactor avx512f: floating point abs
1 parent 3ea862f commit 10f65e4

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

crates/core_arch/src/x86/avx512f.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,7 @@ pub unsafe fn _mm_maskz_abs_epi64(k: __mmask8, a: __m128i) -> __m128i {
258258
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
259259
#[cfg_attr(test, assert_instr(vpandq))]
260260
pub unsafe fn _mm512_abs_ps(v2: __m512) -> __m512 {
261-
let a = _mm512_set1_epi32(0x7FFFFFFF); // from LLVM code
262-
let b = transmute::<f32x16, __m512i>(v2.as_f32x16());
263-
let abs = _mm512_and_epi32(a, b);
264-
transmute(abs)
261+
simd_fabs(v2)
265262
}
266263

267264
/// Finds the absolute value of each packed single-precision (32-bit) floating-point element in v2, storing the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -272,8 +269,7 @@ pub unsafe fn _mm512_abs_ps(v2: __m512) -> __m512 {
272269
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
273270
#[cfg_attr(test, assert_instr(vpandd))]
274271
pub unsafe fn _mm512_mask_abs_ps(src: __m512, k: __mmask16, v2: __m512) -> __m512 {
275-
let abs = _mm512_abs_ps(v2).as_f32x16();
276-
transmute(simd_select_bitmask(k, abs, src.as_f32x16()))
272+
simd_select_bitmask(k, simd_fabs(v2), src)
277273
}
278274

279275
/// Finds the absolute value of each packed double-precision (64-bit) floating-point element in v2, storing the results in dst.
@@ -284,10 +280,7 @@ pub unsafe fn _mm512_mask_abs_ps(src: __m512, k: __mmask16, v2: __m512) -> __m51
284280
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
285281
#[cfg_attr(test, assert_instr(vpandq))]
286282
pub unsafe fn _mm512_abs_pd(v2: __m512d) -> __m512d {
287-
let a = _mm512_set1_epi64(0x7FFFFFFFFFFFFFFF); // from LLVM code
288-
let b = transmute::<f64x8, __m512i>(v2.as_f64x8());
289-
let abs = _mm512_and_epi64(a, b);
290-
transmute(abs)
283+
simd_fabs(v2)
291284
}
292285

293286
/// Finds the absolute value of each packed double-precision (64-bit) floating-point element in v2, storing the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -298,8 +291,7 @@ pub unsafe fn _mm512_abs_pd(v2: __m512d) -> __m512d {
298291
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
299292
#[cfg_attr(test, assert_instr(vpandq))]
300293
pub unsafe fn _mm512_mask_abs_pd(src: __m512d, k: __mmask8, v2: __m512d) -> __m512d {
301-
let abs = _mm512_abs_pd(v2).as_f64x8();
302-
transmute(simd_select_bitmask(k, abs, src.as_f64x8()))
294+
simd_select_bitmask(k, simd_fabs(v2), src)
303295
}
304296

305297
/// Move packed 32-bit integers from a to dst using writemask k (elements are copied from src when the corresponding mask bit is not set).

0 commit comments

Comments
 (0)