2 core_arch
::{simd::*, simd_llvm::*, x86::*}
,
3 mem
::{self, transmute}
,
7 use stdsimd_test
::assert_instr
;
9 /// Computes the absolute values of packed 32-bit integers in `a`.
11 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#avx512techs=AVX512F&expand=33,34,4990,33&text=_mm512_abs_epi32)
13 #[target_feature(enable = "avx512f")]
14 #[cfg_attr(test, assert_instr(vpabsd))]
15 pub unsafe fn _mm512_abs_epi32(a
: __m512i
) -> __m512i
{
16 let a
= a
.as_i32x16();
17 // all-0 is a properly initialized i32x16
18 let zero
: i32x16
= mem
::zeroed();
19 let sub
= simd_sub(zero
, a
);
20 let cmp
: i32x16
= simd_gt(a
, zero
);
21 transmute(simd_select(cmp
, a
, sub
))
24 /// Computes the absolute value of packed 32-bit integers in `a`, and store the
25 /// unsigned results in `dst` using writemask `k` (elements are copied from
26 /// `src` when the corresponding mask bit is not set).
28 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#avx512techs=AVX512F&expand=33,34,4990,33&text=_mm512_abs_epi32)
30 #[target_feature(enable = "avx512f")]
31 #[cfg_attr(test, assert_instr(vpabsd))]
32 pub unsafe fn _mm512_mask_abs_epi32(src
: __m512i
, k
: __mmask16
, a
: __m512i
) -> __m512i
{
33 let abs
= _mm512_abs_epi32(a
).as_i32x16();
34 transmute(simd_select_bitmask(k
, abs
, src
.as_i32x16()))
37 /// Computes the absolute value of packed 32-bit integers in `a`, and store the
38 /// unsigned results in `dst` using zeromask `k` (elements are zeroed out when
39 /// the corresponding mask bit is not set).
41 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#avx512techs=AVX512F&expand=33,34,4990,33,34,35,35&text=_mm512_maskz_abs_epi32)
43 #[target_feature(enable = "avx512f")]
44 #[cfg_attr(test, assert_instr(vpabsd))]
45 pub unsafe fn _mm512_maskz_abs_epi32(k
: __mmask16
, a
: __m512i
) -> __m512i
{
46 let abs
= _mm512_abs_epi32(a
).as_i32x16();
47 let zero
= _mm512_setzero_si512().as_i32x16();
48 transmute(simd_select_bitmask(k
, abs
, zero
))
51 /// Returns vector of type `__m512i` with all elements set to zero.
53 /// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#avx512techs=AVX512F&expand=33,34,4990&text=_mm512_setzero_si512)
55 #[target_feature(enable = "avx512f")]
56 #[cfg_attr(test, assert_instr(vxorps))]
57 pub unsafe fn _mm512_setzero_si512() -> __m512i
{
58 // All-0 is a properly initialized __m512i
62 /// Sets packed 32-bit integers in `dst` with the supplied values in reverse
65 #[target_feature(enable = "avx512f")]
66 pub unsafe fn _mm512_setr_epi32(
85 e15
, e14
, e13
, e12
, e11
, e10
, e9
, e8
, e7
, e6
, e5
, e4
, e3
, e2
, e1
, e0
,
90 /// Broadcast 64-bit integer `a` to all elements of `dst`.
92 #[target_feature(enable = "avx512f")]
93 pub unsafe fn _mm512_set1_epi64(a
: i64) -> __m512i
{
94 transmute(i64x8
::splat(a
))
100 use stdsimd_test
::simd_test
;
102 use crate::core_arch
::x86
::*;
104 #[simd_test(enable = "avx512f")]
105 unsafe fn test_mm512_abs_epi32() {
107 let a
= _mm512_setr_epi32(
108 0, 1, -1, std
::i32::MAX
,
109 std
::i32::MIN
, 100, -100, -32,
110 0, 1, -1, std
::i32::MAX
,
111 std
::i32::MIN
, 100, -100, -32,
113 let r
= _mm512_abs_epi32(a
);
114 let e
= _mm512_setr_epi32(
119 std
::i32::MAX
.wrapping_add(1),
127 std
::i32::MAX
.wrapping_add(1),
132 assert_eq_m512i(r
, e
);
135 #[simd_test(enable = "avx512f")]
136 unsafe fn test_mm512_mask_abs_epi32() {
138 let a
= _mm512_setr_epi32(
139 0, 1, -1, std
::i32::MAX
,
140 std
::i32::MIN
, 100, -100, -32,
141 0, 1, -1, std
::i32::MAX
,
142 std
::i32::MIN
, 100, -100, -32,
144 let r
= _mm512_mask_abs_epi32(a
, 0, a
);
145 assert_eq_m512i(r
, a
);
146 let r
= _mm512_mask_abs_epi32(a
, 0b11111111, a
);
147 let e
= _mm512_setr_epi32(
152 std
::i32::MAX
.wrapping_add(1),
165 assert_eq_m512i(r
, e
);
168 #[simd_test(enable = "avx512f")]
169 unsafe fn test_mm512_maskz_abs_epi32() {
171 let a
= _mm512_setr_epi32(
172 0, 1, -1, std
::i32::MAX
,
173 std
::i32::MIN
, 100, -100, -32,
174 0, 1, -1, std
::i32::MAX
,
175 std
::i32::MIN
, 100, -100, -32,
177 let r
= _mm512_maskz_abs_epi32(0, a
);
178 assert_eq_m512i(r
, _mm512_setzero_si512());
179 let r
= _mm512_maskz_abs_epi32(0b11111111, a
);
180 let e
= _mm512_setr_epi32(
185 std
::i32::MAX
.wrapping_add(1),
198 assert_eq_m512i(r
, e
);