Debian Codegraph @

debian/missing-sources/safe_arch/src/x86_x64/avx.rs

raw
1 #![cfg(target_feature = "avx")]
2
3 use super::*;
4
5 /// Lanewise `a + b` with `f64` lanes.
6 ///
7 /// * **Intrinsic:** [``]
8 /// * **Assembly:**
9 #[must_use]
10 #[inline(always)]
11 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
12 pub fn add_m256d(a: m256d, b: m256d) -> m256d {
13 m256d(unsafe { _mm256_add_pd(a.0, b.0) })
14 }
15
16 /// Lanewise `a + b` with `f32` lanes.
17 ///
18 /// * **Intrinsic:** [``]
19 /// * **Assembly:**
20 #[must_use]
21 #[inline(always)]
22 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
23 pub fn add_m256(a: m256, b: m256) -> m256 {
24 m256(unsafe { _mm256_add_ps(a.0, b.0) })
25 }
26
27 /// Alternately, from the top, add `f64` then sub `f64`.
28 ///
29 /// * **Intrinsic:** [``]
30 /// * **Assembly:**
31 #[must_use]
32 #[inline(always)]
33 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
34 pub fn addsub_m256d(a: m256d, b: m256d) -> m256d {
35 m256d(unsafe { _mm256_addsub_pd(a.0, b.0) })
36 }
37
38 /// Alternately, from the top, add `f32` then sub `f32`.
39 ///
40 /// * **Intrinsic:** [``]
41 /// * **Assembly:**
42 #[must_use]
43 #[inline(always)]
44 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
45 pub fn addsub_m256(a: m256, b: m256) -> m256 {
46 m256(unsafe { _mm256_addsub_ps(a.0, b.0) })
47 }
48
49 /// Bitwise `a & b`.
50 ///
51 /// * **Intrinsic:** [``]
52 /// * **Assembly:**
53 #[must_use]
54 #[inline(always)]
55 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
56 pub fn bitand_m256d(a: m256d, b: m256d) -> m256d {
57 m256d(unsafe { _mm256_and_pd(a.0, b.0) })
58 }
59
60 /// Bitwise `a & b`.
61 ///
62 /// * **Intrinsic:** [``]
63 /// * **Assembly:**
64 #[must_use]
65 #[inline(always)]
66 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
67 pub fn bitand_m256(a: m256, b: m256) -> m256 {
68 m256(unsafe { _mm256_and_ps(a.0, b.0) })
69 }
70
71 /// Bitwise `(!a) & b`.
72 ///
73 /// * **Intrinsic:** [``]
74 /// * **Assembly:**
75 #[must_use]
76 #[inline(always)]
77 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
78 pub fn bitandnot_m256d(a: m256d, b: m256d) -> m256d {
79 m256d(unsafe { _mm256_andnot_pd(a.0, b.0) })
80 }
81
82 /// Bitwise `(!a) & b`.
83 ///
84 /// * **Intrinsic:** [``]
85 /// * **Assembly:**
86 #[must_use]
87 #[inline(always)]
88 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
89 pub fn bitandnot_m256(a: m256, b: m256) -> m256 {
90 m256(unsafe { _mm256_andnot_ps(a.0, b.0) })
91 }
92
93 /// Blends the `f64` lanes according to the immediate mask.
94 ///
95 /// Each bit 0 though 3 controls output lane 0 through 3. Use 0 for the `a`
96 /// value and 1 for the `b` value.
97 ///
98 /// * **Intrinsic:** [``]
99 /// * **Assembly:**
100 #[must_use]
101 #[inline(always)]
102 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
103 pub fn blend_m256d<const IMM: i32>(a: m256d, b: m256d) -> m256d {
104 m256d(unsafe { _mm256_blend_pd(a.0, b.0, IMM) })
105 }
106
107 /// Blends the `f32` lanes according to the immediate mask.
108 ///
109 /// Each bit 0 though 7 controls lane 0 through 7. Use 0 for the `$a` value and
110 /// 1 for the `$b` value.
111 ///
112 /// * **Intrinsic:** [``]
113 /// * **Assembly:**
114 #[must_use]
115 #[inline(always)]
116 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
117 pub fn blend_m256<const IMM: i32>(a: m256, b: m256) -> m256 {
118 m256(unsafe { _mm256_blend_ps(a.0, b.0, IMM) })
119 }
120
121 /// Blend the lanes according to a runtime varying mask.
122 ///
123 /// The sign bit of each lane in the `mask` value determines if the output
124 /// lane uses `a` (mask non-negative) or `b` (mask negative).
125 ///
126 /// * **Intrinsic:** [``]
127 /// * **Assembly:**
128 #[must_use]
129 #[inline(always)]
130 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
131 pub fn blend_varying_m256d(a: m256d, b: m256d, mask: m256d) -> m256d {
132 m256d(unsafe { _mm256_blendv_pd(a.0, b.0, mask.0) })
133 }
134
135 /// Blend the lanes according to a runtime varying mask.
136 ///
137 /// The sign bit of each lane in the `mask` value determines if the output
138 /// lane uses `a` (mask non-negative) or `b` (mask negative).
139 ///
140 /// * **Intrinsic:** [``]
141 /// * **Assembly:**
142 #[must_use]
143 #[inline(always)]
144 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
145 pub fn blend_varying_m256(a: m256, b: m256, mask: m256) -> m256 {
146 m256(unsafe { _mm256_blendv_ps(a.0, b.0, mask.0) })
147 }
148
149 /// Load an `m128d` and splat it to the lower and upper half of an `m256d`
150 ///
151 /// * **Intrinsic:** [``]
152 /// * **Assembly:**
153 #[must_use]
154 #[inline(always)]
155 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
156 pub fn load_m128d_splat_m256d(a: &m128d) -> m256d {
157 m256d(unsafe { _mm256_broadcast_pd(&a.0) })
158 }
159
160 /// Load an `m128` and splat it to the lower and upper half of an `m256`
161 ///
162 /// * **Intrinsic:** [``]
163 /// * **Assembly:**
164 #[must_use]
165 #[inline(always)]
166 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
167 pub fn load_m128_splat_m256(a: &m128) -> m256 {
168 m256(unsafe { _mm256_broadcast_ps(&a.0) })
169 }
170
171 /// Load an `f64` and splat it to all lanes of an `m256d`
172 ///
173 /// * **Intrinsic:** [``]
174 /// * **Assembly:**
175 #[must_use]
176 #[inline(always)]
177 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
178 pub fn load_f64_splat_m256d(a: &f64) -> m256d {
179 m256d(unsafe { _mm256_broadcast_sd(a) })
180 }
181
182 /// Load an `f32` and splat it to all lanes of an `m256d`
183 ///
184 /// * **Intrinsic:** [``]
185 /// * **Assembly:**
186 #[must_use]
187 #[inline(always)]
188 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
189 pub fn load_f32_splat_m256(a: &f32) -> m256 {
190 m256(unsafe { _mm256_broadcast_ss(a) })
191 }
192
193 /// Bit-preserving cast to `m256` from `m256d`.
194 ///
195 /// * **Intrinsic:** [``]
196 /// * **Assembly:**
197 #[must_use]
198 #[inline(always)]
199 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
200 pub fn cast_to_m256_from_m256d(a: m256d) -> m256 {
201 m256(unsafe { _mm256_castpd_ps(a.0) })
202 }
203
204 /// Bit-preserving cast to `m256i` from `m256d`.
205 ///
206 /// * **Intrinsic:** [``]
207 /// * **Assembly:**
208 #[must_use]
209 #[inline(always)]
210 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
211 pub fn cast_to_m256i_from_m256d(a: m256d) -> m256i {
212 m256i(unsafe { _mm256_castpd_si256(a.0) })
213 }
214
215 /// Bit-preserving cast to `m256i` from `m256`.
216 ///
217 /// * **Intrinsic:** [``]
218 /// * **Assembly:**
219 #[must_use]
220 #[inline(always)]
221 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
222 pub fn cast_to_m256d_from_m256(a: m256) -> m256d {
223 m256d(unsafe { _mm256_castps_pd(a.0) })
224 }
225
226 /// Bit-preserving cast to `m256i` from `m256`.
227 ///
228 /// * **Intrinsic:** [``]
229 /// * **Assembly:**
230 #[must_use]
231 #[inline(always)]
232 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
233 pub fn cast_to_m256i_from_m256(a: m256) -> m256i {
234 m256i(unsafe { _mm256_castps_si256(a.0) })
235 }
236
237 /// Bit-preserving cast to `m256d` from `m256i`.
238 ///
239 /// * **Intrinsic:** [``]
240 /// * **Assembly:**
241 #[must_use]
242 #[inline(always)]
243 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
244 pub fn cast_to_m256d_from_m256i(a: m256i) -> m256d {
245 m256d(unsafe { _mm256_castsi256_pd(a.0) })
246 }
247
248 /// Bit-preserving cast to `m256` from `m256i`.
249 ///
250 /// * **Intrinsic:** [``]
251 /// * **Assembly:**
252 #[must_use]
253 #[inline(always)]
254 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
255 pub fn cast_to_m256_from_m256i(a: m256i) -> m256 {
256 m256(unsafe { _mm256_castsi256_ps(a.0) })
257 }
258
259 /// Bit-preserving cast to `m128` from `m256`.
260 ///
261 /// * **Intrinsic:** [``]
262 /// * **Assembly:**
263 #[must_use]
264 #[inline(always)]
265 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
266 pub fn cast_to_m128_from_m256(a: m256) -> m128 {
267 m128(unsafe { _mm256_castps256_ps128(a.0) })
268 }
269
270 /// Bit-preserving cast to `m128d` from `m256d`.
271 ///
272 /// * **Intrinsic:** [``]
273 /// * **Assembly:**
274 #[must_use]
275 #[inline(always)]
276 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
277 pub fn cast_to_m128d_from_m256d(a: m256d) -> m128d {
278 m128d(unsafe { _mm256_castpd256_pd128(a.0) })
279 }
280
281 /// Bit-preserving cast to `m128i` from `m256i`.
282 ///
283 /// * **Intrinsic:** [``]
284 /// * **Assembly:**
285 #[must_use]
286 #[inline(always)]
287 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
288 pub fn cast_to_m128i_from_m256i(a: m256i) -> m128i {
289 m128i(unsafe { _mm256_castsi256_si128(a.0) })
290 }
291
292 /// Round `f64` lanes towards positive infinity.
293 ///
294 /// * **Intrinsic:** [``]
295 /// * **Assembly:**
296 #[must_use]
297 #[inline(always)]
298 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
299 pub fn ceil_m256d(a: m256d) -> m256d {
300 m256d(unsafe { _mm256_ceil_pd(a.0) })
301 }
302
303 /// Round `f32` lanes towards positive infinity.
304 ///
305 /// * **Intrinsic:** [``]
306 /// * **Assembly:**
307 #[must_use]
308 #[inline(always)]
309 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
310 pub fn ceil_m256(a: m256) -> m256 {
311 m256(unsafe { _mm256_ceil_ps(a.0) })
312 }
313
314 /// Turns a comparison operator token to the correct constant value.
315 #[macro_export]
316 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
317 macro_rules! cmp_op {
318 (EqualOrdered) => {{
319 #[cfg(target_arch = "x86")]
320 use ::core::arch::x86::_CMP_EQ_OQ;
321 #[cfg(target_arch = "x86_64")]
322 use ::core::arch::x86_64::_CMP_EQ_OQ;
323 _CMP_EQ_OQ
324 }};
325 (EqualUnordered) => {{
326 #[cfg(target_arch = "x86")]
327 use ::core::arch::x86::_CMP_EQ_UQ;
328 #[cfg(target_arch = "x86_64")]
329 use ::core::arch::x86_64::_CMP_EQ_UQ;
330 _CMP_EQ_UQ
331 }};
332 (False) => {{
333 #[cfg(target_arch = "x86")]
334 use ::core::arch::x86::_CMP_FALSE_OQ;
335 #[cfg(target_arch = "x86_64")]
336 use ::core::arch::x86_64::_CMP_FALSE_OQ;
337 _CMP_FALSE_OQ
338 }};
339 (GreaterEqualOrdered) => {{
340 #[cfg(target_arch = "x86")]
341 use ::core::arch::x86::_CMP_GE_OQ;
342 #[cfg(target_arch = "x86_64")]
343 use ::core::arch::x86_64::_CMP_GE_OQ;
344 _CMP_GE_OQ
345 }};
346 (GreaterThanOrdered) => {{
347 #[cfg(target_arch = "x86")]
348 use ::core::arch::x86::_CMP_GT_OQ;
349 #[cfg(target_arch = "x86_64")]
350 use ::core::arch::x86_64::_CMP_GT_OQ;
351 _CMP_GT_OQ
352 }};
353 (LessEqualOrdered) => {{
354 #[cfg(target_arch = "x86")]
355 use ::core::arch::x86::_CMP_LE_OQ;
356 #[cfg(target_arch = "x86_64")]
357 use ::core::arch::x86_64::_CMP_LE_OQ;
358 _CMP_LE_OQ
359 }};
360 (LessThanOrdered) => {{
361 #[cfg(target_arch = "x86")]
362 use ::core::arch::x86::_CMP_LT_OQ;
363 #[cfg(target_arch = "x86_64")]
364 use ::core::arch::x86_64::_CMP_LT_OQ;
365 _CMP_LT_OQ
366 }};
367 (NotEqualOrdered) => {{
368 #[cfg(target_arch = "x86")]
369 use ::core::arch::x86::_CMP_NEQ_OQ;
370 #[cfg(target_arch = "x86_64")]
371 use ::core::arch::x86_64::_CMP_NEQ_OQ;
372 _CMP_NEQ_OQ
373 }};
374 (NotEqualUnordered) => {{
375 #[cfg(target_arch = "x86")]
376 use ::core::arch::x86::_CMP_NEQ_UQ;
377 #[cfg(target_arch = "x86_64")]
378 use ::core::arch::x86_64::_CMP_NEQ_UQ;
379 _CMP_NEQ_UQ
380 }};
381 (NotGreaterEqualUnordered) => {{
382 #[cfg(target_arch = "x86")]
383 use ::core::arch::x86::_CMP_NGE_UQ;
384 #[cfg(target_arch = "x86_64")]
385 use ::core::arch::x86_64::_CMP_NGE_UQ;
386 _CMP_NGE_UQ
387 }};
388 (NotGreaterThanUnordered) => {{
389 #[cfg(target_arch = "x86")]
390 use ::core::arch::x86::_CMP_NGT_UQ;
391 #[cfg(target_arch = "x86_64")]
392 use ::core::arch::x86_64::_CMP_NGT_UQ;
393 _CMP_NGT_UQ
394 }};
395 (NotLessEqualUnordered) => {{
396 #[cfg(target_arch = "x86")]
397 use ::core::arch::x86::_CMP_NLE_UQ;
398 #[cfg(target_arch = "x86_64")]
399 use ::core::arch::x86_64::_CMP_NLE_UQ;
400 _CMP_NLE_UQ
401 }};
402 (NotLessThanUnordered) => {{
403 #[cfg(target_arch = "x86")]
404 use ::core::arch::x86::_CMP_NLT_UQ;
405 #[cfg(target_arch = "x86_64")]
406 use ::core::arch::x86_64::_CMP_NLT_UQ;
407 _CMP_NLT_UQ
408 }};
409 (Ordered) => {{
410 #[cfg(target_arch = "x86")]
411 use ::core::arch::x86::_CMP_ORD_Q;
412 #[cfg(target_arch = "x86_64")]
413 use ::core::arch::x86_64::_CMP_ORD_Q;
414 _CMP_ORD_Q
415 }};
416 (True) => {{
417 #[cfg(target_arch = "x86")]
418 use ::core::arch::x86::_CMP_TRUE_UQ;
419 #[cfg(target_arch = "x86_64")]
420 use ::core::arch::x86_64::_CMP_TRUE_UQ;
421 _CMP_TRUE_UQ
422 }};
423 (Unordered) => {{
424 #[cfg(target_arch = "x86")]
425 use ::core::arch::x86::_CMP_UNORD_Q;
426 #[cfg(target_arch = "x86_64")]
427 use ::core::arch::x86_64::_CMP_UNORD_Q;
428 _CMP_UNORD_Q
429 }};
430 ($unknown_op:tt) => {{
431 compile_error!("The operation name given is invalid.");
432 }};
433 }
434
435 /// Compare `f32` lanes according to the operation specified, mask output.
436 ///
437 /// * Operators are according to the [`cmp_op`] macro.
438 ///
439 /// * **Intrinsic:** [``]
440 /// * **Assembly:**
441 #[must_use]
442 #[inline(always)]
443 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
444 pub fn cmp_op_mask_m128<const OP: i32>(a: m128, b: m128) -> m128 {
445 m128(unsafe { _mm_cmp_ps(a.0, b.0, OP) })
446 }
447
448 /// Compare `f32` lanes according to the operation specified, mask output.
449 ///
450 /// * Operators are according to the [`cmp_op`] macro.
451 ///
452 /// * **Intrinsic:** [``]
453 /// * **Assembly:**
454 #[must_use]
455 #[inline(always)]
456 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
457 pub fn cmp_op_mask_m128_s<const OP: i32>(a: m128, b: m128) -> m128 {
458 m128(unsafe { _mm_cmp_ss(a.0, b.0, OP) })
459 }
460
461 /// Compare `f32` lanes according to the operation specified, mask output.
462 ///
463 /// * Operators are according to the [`cmp_op`] macro.
464 ///
465 /// * **Intrinsic:** [``]
466 /// * **Assembly:**
467 #[must_use]
468 #[inline(always)]
469 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
470 pub fn cmp_op_mask_m256<const OP: i32>(a: m256, b: m256) -> m256 {
471 m256(unsafe { _mm256_cmp_ps(a.0, b.0, OP) })
472 }
473
474 /// Compare `f64` lanes according to the operation specified, mask output.
475 ///
476 /// * Operators are according to the [`cmp_op`] macro.
477 ///
478 /// * **Intrinsic:** [``]
479 /// * **Assembly:**
480 #[must_use]
481 #[inline(always)]
482 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
483 pub fn cmp_op_mask_m128d<const OP: i32>(a: m128d, b: m128d) -> m128d {
484 m128d(unsafe { _mm_cmp_pd(a.0, b.0, OP) })
485 }
486
487 /// Compare `f64` lanes according to the operation specified, mask output.
488 ///
489 /// * Operators are according to the [`cmp_op`] macro.
490 ///
491 /// * **Intrinsic:** [``]
492 /// * **Assembly:**
493 #[must_use]
494 #[inline(always)]
495 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
496 pub fn cmp_op_mask_m128d_s<const OP: i32>(a: m128d, b: m128d) -> m128d {
497 m128d(unsafe { _mm_cmp_sd(a.0, b.0, OP) })
498 }
499
500 /// Compare `f64` lanes according to the operation specified, mask output.
501 ///
502 /// * Operators are according to the [`cmp_op`] macro.
503 ///
504 /// * **Intrinsic:** [``]
505 /// * **Assembly:**
506 #[must_use]
507 #[inline(always)]
508 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
509 pub fn cmp_op_mask_m256d<const OP: i32>(a: m256d, b: m256d) -> m256d {
510 m256d(unsafe { _mm256_cmp_pd(a.0, b.0, OP) })
511 }
512
513 /// Convert `i32` lanes to be `f64` lanes.
514 ///
515 /// * **Intrinsic:** [`_mm256_cvtepi32_pd`]
516 /// * **Assembly:** `vcvtdq2pd ymm, xmm`
517 #[must_use]
518 #[inline(always)]
519 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
520 pub fn convert_to_m256d_from_i32_m128i(a: m128i) -> m256d {
521 m256d(unsafe { _mm256_cvtepi32_pd(a.0) })
522 }
523
524 /// Convert `i32` lanes to be `f32` lanes.
525 ///
526 /// * **Intrinsic:** [`_mm256_cvtepi32_ps`]
527 /// * **Assembly:** `vcvtdq2ps ymm, ymm`
528 #[must_use]
529 #[inline(always)]
530 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
531 pub fn convert_to_m256_from_i32_m256i(a: m256i) -> m256 {
532 m256(unsafe { _mm256_cvtepi32_ps(a.0) })
533 }
534
535 /// Convert `f64` lanes to be `i32` lanes.
536 ///
537 /// * **Intrinsic:** [`_mm256_cvtpd_epi32`]
538 /// * **Assembly:** `vcvtpd2dq xmm, ymm`
539 #[must_use]
540 #[inline(always)]
541 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
542 pub fn convert_to_i32_m128i_from_m256d(a: m256d) -> m128i {
543 m128i(unsafe { _mm256_cvtpd_epi32(a.0) })
544 }
545
546 /// Convert `f64` lanes to be `f32` lanes.
547 ///
548 /// * **Intrinsic:** [`_mm256_cvtpd_ps`]
549 /// * **Assembly:** `vcvtpd2ps xmm, ymm`
550 #[must_use]
551 #[inline(always)]
552 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
553 pub fn convert_to_m128_from_m256d(a: m256d) -> m128 {
554 m128(unsafe { _mm256_cvtpd_ps(a.0) })
555 }
556
557 /// Convert `f32` lanes to be `i32` lanes.
558 ///
559 /// * **Intrinsic:** [`_mm256_cvtps_epi32`]
560 /// * **Assembly:** `vcvtps2dq ymm, ymm`
561 #[must_use]
562 #[inline(always)]
563 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
564 pub fn convert_to_i32_m256i_from_m256(a: m256) -> m256i {
565 m256i(unsafe { _mm256_cvtps_epi32(a.0) })
566 }
567
568 /// Convert `f32` lanes to be `f64` lanes.
569 ///
570 /// * **Intrinsic:** [`_mm256_cvtps_pd`]
571 /// * **Assembly:** `vcvtps2pd ymm, xmm`
572 #[must_use]
573 #[inline(always)]
574 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
575 pub fn convert_to_m256d_from_m128(a: m128) -> m256d {
576 m256d(unsafe { _mm256_cvtps_pd(a.0) })
577 }
578
579 /// Convert the lowest `f64` lane to a single `f64`.
580 ///
581 /// * **Intrinsic:** [`_mm256_cvtsd_f64`]
582 /// * **Assembly:** `vmovsd m64, xmm`
583 #[must_use]
584 #[inline(always)]
585 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
586 pub fn convert_to_f64_from_m256d_s(a: m256d) -> f64 {
587 unsafe { _mm256_cvtsd_f64(a.0) }
588 }
589
590 /// Convert the lowest `i32` lane to a single `i32`.
591 ///
592 /// * **Intrinsic:** [`_mm256_cvtsi256_si32`]
593 /// * **Assembly:** `vmovd r32, xmm`
594 #[must_use]
595 #[inline(always)]
596 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
597 pub fn convert_to_i32_from_m256i_s(a: m256i) -> i32 {
598 unsafe { _mm256_cvtsi256_si32(a.0) }
599 }
600
601 /// Convert the lowest `f32` lane to a single `f32`.
602 ///
603 /// * **Intrinsic:** [`_mm256_cvtss_f32`]
604 /// * **Assembly:** `vmovss m32, xmm`
605 #[must_use]
606 #[inline(always)]
607 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
608 pub fn convert_to_f32_from_m256_s(a: m256) -> f32 {
609 unsafe { _mm256_cvtss_f32(a.0) }
610 }
611
612 /// Convert `f64` lanes to `i32` lanes with truncation.
613 ///
614 /// * **Intrinsic:** [`_mm256_cvttpd_epi32`]
615 /// * **Assembly:** `vcvttpd2dq xmm, ymm`
616 #[must_use]
617 #[inline(always)]
618 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
619 pub fn convert_truncate_to_i32_m128i_from_m256d(a: m256d) -> m128i {
620 m128i(unsafe { _mm256_cvttpd_epi32(a.0) })
621 }
622
623 /// Convert `f32` lanes to `i32` lanes with truncation.
624 ///
625 /// * **Intrinsic:** [`_mm256_cvttps_epi32`]
626 /// * **Assembly:** ``
627 #[must_use]
628 #[inline(always)]
629 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
630 pub fn convert_truncate_to_i32_m256i_from_m256(a: m256) -> m256i {
631 m256i(unsafe { _mm256_cvttps_epi32(a.0) })
632 }
633
634 /// Lanewise `a / b` with `f64`.
635 ///
636 /// * **Intrinsic:** [``]
637 /// * **Assembly:**
638 #[must_use]
639 #[inline(always)]
640 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
641 pub fn div_m256d(a: m256d, b: m256d) -> m256d {
642 m256d(unsafe { _mm256_div_pd(a.0, b.0) })
643 }
644
645 /// Lanewise `a / b` with `f32`.
646 ///
647 /// * **Intrinsic:** [``]
648 /// * **Assembly:**
649 #[must_use]
650 #[inline(always)]
651 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
652 pub fn div_m256(a: m256, b: m256) -> m256 {
653 m256(unsafe { _mm256_div_ps(a.0, b.0) })
654 }
655
656 /// This works like [`dot_product_m128`], but twice as wide.
657 ///
658 /// The given control is used for the lower 4 lanes and then separately also the
659 /// upper four lanes. See the other macro for more info on how the control
660 /// works.
661 ///
662 /// * **Intrinsic:** [``]
663 /// * **Assembly:**
664 #[must_use]
665 #[inline(always)]
666 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
667 pub fn dot_product_m256<const IMM: i32>(a: m256, b: m256) -> m256 {
668 m256(unsafe { _mm256_dp_ps(a.0, b.0, IMM) })
669 }
670
671 /// Extracts an `i32` lane from `m256i`
672 ///
673 /// * **Intrinsic:** [``]
674 /// * **Assembly:**
675 #[must_use]
676 #[inline(always)]
677 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
678 pub fn extract_i32_from_m256i<const IMM: i32>(a: m256i) -> i32 {
679 unsafe { _mm256_extract_epi32(a.0, IMM) }
680 }
681
682 /// Extracts an `i64` lane from `m256i`
683 ///
684 /// * **Intrinsic:** [``]
685 /// * **Assembly:**
686 #[must_use]
687 #[inline(always)]
688 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
689 #[cfg(target_arch = "x86_64")]
690 pub fn extract_i64_from_m256i<const IMM: i32>(a: m256i) -> i64 {
691 unsafe { _mm256_extract_epi64(a.0, IMM) }
692 }
693
694 /// Extracts an `m128d` from `m256d`
695 ///
696 /// * **Intrinsic:** [``]
697 /// * **Assembly:**
698 #[must_use]
699 #[inline(always)]
700 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
701 pub fn extract_m128d_from_m256d<const IMM: i32>(a: m256d) -> m128d {
702 m128d(unsafe { _mm256_extractf128_pd(a.0, IMM) })
703 }
704
705 /// Extracts an `m128` from `m256`
706 ///
707 /// * **Intrinsic:** [``]
708 /// * **Assembly:**
709 #[must_use]
710 #[inline(always)]
711 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
712 pub fn extract_m128_from_m256<const IMM: i32>(a: m256) -> m128 {
713 m128(unsafe { _mm256_extractf128_ps(a.0, IMM) })
714 }
715
716 /// Extracts an `m128i` from `m256i`
717 ///
718 /// * **Intrinsic:** [``]
719 /// * **Assembly:**
720 #[must_use]
721 #[inline(always)]
722 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
723 pub fn extract_m128i_from_m256i<const IMM: i32>(a: m256i) -> m128i {
724 m128i(unsafe { _mm256_extractf128_si256(a.0, IMM) })
725 }
726
727 /// Round `f64` lanes towards negative infinity.
728 ///
729 /// * **Intrinsic:** [``]
730 /// * **Assembly:**
731 #[must_use]
732 #[inline(always)]
733 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
734 pub fn floor_m256d(a: m256d) -> m256d {
735 m256d(unsafe { _mm256_floor_pd(a.0) })
736 }
737
738 /// Round `f32` lanes towards negative infinity.
739 ///
740 /// * **Intrinsic:** [``]
741 /// * **Assembly:**
742 #[must_use]
743 #[inline(always)]
744 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
745 pub fn floor_m256(a: m256) -> m256 {
746 m256(unsafe { _mm256_floor_ps(a.0) })
747 }
748
749 /// Add adjacent `f64` lanes.
750 ///
751 /// * **Intrinsic:** [``]
752 /// * **Assembly:**
753 #[must_use]
754 #[inline(always)]
755 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
756 pub fn add_horizontal_m256d(a: m256d, b: m256d) -> m256d {
757 m256d(unsafe { _mm256_hadd_pd(a.0, b.0) })
758 }
759
760 /// Add adjacent `f32` lanes.
761 ///
762 /// * **Intrinsic:** [``]
763 /// * **Assembly:**
764 #[must_use]
765 #[inline(always)]
766 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
767 pub fn add_horizontal_m256(a: m256, b: m256) -> m256 {
768 m256(unsafe { _mm256_hadd_ps(a.0, b.0) })
769 }
770
771 /// Subtract adjacent `f64` lanes.
772 ///
773 /// * **Intrinsic:** [``]
774 /// * **Assembly:**
775 #[must_use]
776 #[inline(always)]
777 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
778 pub fn sub_horizontal_m256d(a: m256d, b: m256d) -> m256d {
779 m256d(unsafe { _mm256_hsub_pd(a.0, b.0) })
780 }
781
782 /// Subtract adjacent `f32` lanes.
783 ///
784 /// * **Intrinsic:** [``]
785 /// * **Assembly:**
786 #[must_use]
787 #[inline(always)]
788 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
789 pub fn sub_horizontal_m256(a: m256, b: m256) -> m256 {
790 m256(unsafe { _mm256_hsub_ps(a.0, b.0) })
791 }
792
793 /// Inserts an `i8` to `m256i`
794 ///
795 /// * **Intrinsic:** [``]
796 /// * **Assembly:**
797 #[must_use]
798 #[inline(always)]
799 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
800 pub fn insert_i8_to_m256i<const IMM: i32>(a: m256i, i: i8) -> m256i {
801 m256i(unsafe { _mm256_insert_epi8(a.0, i, IMM) })
802 }
803
804 /// Inserts an `i16` to `m256i`
805 ///
806 /// * **Intrinsic:** [``]
807 /// * **Assembly:**
808 #[must_use]
809 #[inline(always)]
810 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
811 pub fn insert_i16_to_m256i<const IMM: i32>(a: m256i, i: i16) -> m256i {
812 m256i(unsafe { _mm256_insert_epi16(a.0, i, IMM) })
813 }
814
815 /// Inserts an `i32` to `m256i`
816 ///
817 /// * **Intrinsic:** [``]
818 /// * **Assembly:**
819 #[must_use]
820 #[inline(always)]
821 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
822 pub fn insert_i32_to_m256i<const IMM: i32>(a: m256i, i: i32) -> m256i {
823 m256i(unsafe { _mm256_insert_epi32(a.0, i, IMM) })
824 }
825
826 /// Inserts an `i64` to `m256i`
827 ///
828 /// * **Intrinsic:** [``]
829 /// * **Assembly:**
830 #[must_use]
831 #[inline(always)]
832 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
833 #[cfg(target_arch = "x86_64")]
834 pub fn insert_i64_to_m256i<const IMM: i32>(a: m256i, i: i64) -> m256i {
835 m256i(unsafe { _mm256_insert_epi64(a.0, i, IMM) })
836 }
837
838 /// Inserts an `m128d` to `m256d`
839 ///
840 /// * **Intrinsic:** [``]
841 /// * **Assembly:**
842 #[must_use]
843 #[inline(always)]
844 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
845 pub fn insert_m128d_to_m256d<const IMM: i32>(a: m256d, b: m128d) -> m256d {
846 m256d(unsafe { _mm256_insertf128_pd(a.0, b.0, IMM) })
847 }
848
849 /// Inserts an `m128` to `m256`
850 ///
851 /// * **Intrinsic:** [``]
852 /// * **Assembly:**
853 #[must_use]
854 #[inline(always)]
855 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
856 pub fn insert_m128_to_m256<const IMM: i32>(a: m256, b: m128) -> m256 {
857 m256(unsafe { _mm256_insertf128_ps(a.0, b.0, IMM) })
858 }
859
860 /// Slowly inserts an `m128i` to `m256i`.
861 ///
862 /// This is a "historical artifact" that was potentially useful if you have AVX
863 /// but not AVX2. If you plan on having AVX2 available please use
864 /// [`insert_m128i_to_m256i`], it will do the same task with better performance.
865 ///
866 /// * **Intrinsic:** [``]
867 /// * **Assembly:**
868 #[must_use]
869 #[inline(always)]
870 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
871 pub fn insert_m128i_to_m256i_slow_avx<const IMM: i32>(a: m256i, b: m128i) -> m256i {
872 m256i(unsafe { _mm256_insertf128_si256(a.0, b.0, IMM) })
873 }
874
875 /// Load data from memory into a register.
876 ///
877 /// * **Intrinsic:** [``]
878 /// * **Assembly:**
879 #[must_use]
880 #[inline(always)]
881 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
882 pub fn load_m256d(a: &m256d) -> m256d {
883 m256d(unsafe { _mm256_load_pd(a as *const m256d as *const f64) })
884 }
885
886 /// Load data from memory into a register.
887 ///
888 /// * **Intrinsic:** [``]
889 /// * **Assembly:**
890 #[must_use]
891 #[inline(always)]
892 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
893 pub fn load_m256(a: &m256) -> m256 {
894 m256(unsafe { _mm256_load_ps(a as *const m256 as *const f32) })
895 }
896
897 /// Load data from memory into a register.
898 ///
899 /// * **Intrinsic:** [``]
900 /// * **Assembly:**
901 #[must_use]
902 #[inline(always)]
903 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
904 pub fn load_m256i(a: &m256i) -> m256i {
905 m256i(unsafe { _mm256_load_si256(a as *const m256i as *const __m256i) })
906 }
907
908 /// Load data from memory into a register.
909 ///
910 /// * **Intrinsic:** [``]
911 /// * **Assembly:**
912 #[must_use]
913 #[inline(always)]
914 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
915 pub fn load_unaligned_m256d(a: &[f64; 4]) -> m256d {
916 m256d(unsafe { _mm256_loadu_pd(a as *const [f64; 4] as *const f64) })
917 }
918
919 /// Load data from memory into a register.
920 ///
921 /// * **Intrinsic:** [``]
922 /// * **Assembly:**
923 #[must_use]
924 #[inline(always)]
925 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
926 pub fn load_unaligned_m256(a: &[f32; 8]) -> m256 {
927 m256(unsafe { _mm256_loadu_ps(a as *const [f32; 8] as *const f32) })
928 }
929
930 /// Load data from memory into a register.
931 ///
932 /// * **Intrinsic:** [``]
933 /// * **Assembly:**
934 #[must_use]
935 #[inline(always)]
936 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
937 pub fn load_unaligned_m256i(a: &[i8; 32]) -> m256i {
938 m256i(unsafe { _mm256_loadu_si256(a as *const [i8; 32] as *const __m256i) })
939 }
940
941 /// Load data from memory into a register.
942 ///
943 /// * **Intrinsic:** [``]
944 /// * **Assembly:**
945 #[must_use]
946 #[inline(always)]
947 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
948 pub fn load_unaligned_hi_lo_m256d(a: &[f64; 2], b: &[f64; 2]) -> m256d {
949 m256d(unsafe { _mm256_loadu2_m128d(a as *const [f64; 2] as *const f64, b as *const [f64; 2] as *const f64) })
950 }
951
952 /// Load data from memory into a register.
953 ///
954 /// * **Intrinsic:** [``]
955 /// * **Assembly:**
956 #[must_use]
957 #[inline(always)]
958 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
959 pub fn load_unaligned_hi_lo_m256(a: &[f32; 4], b: &[f32; 4]) -> m256 {
960 m256(unsafe { _mm256_loadu2_m128(a as *const [f32; 4] as *const f32, b as *const [f32; 4] as *const f32) })
961 }
962
963 /// Load data from memory into a register.
964 ///
965 /// * **Intrinsic:** [``]
966 /// * **Assembly:**
967 #[must_use]
968 #[inline(always)]
969 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
970 pub fn load_unaligned_hi_lo_m256i(a: &[i8; 16], b: &[i8; 16]) -> m256i {
971 m256i(unsafe { _mm256_loadu2_m128i(a as *const [i8; 16] as *const __m128i, b as *const [i8; 16] as *const __m128i) })
972 }
973
974 /// Load data from memory into a register according to a mask.
975 ///
976 /// When the high bit of a mask lane isn't set the loaded lane will be zero.
977 ///
978 /// * **Intrinsic:** [``]
979 /// * **Assembly:**
980 #[must_use]
981 #[inline(always)]
982 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
983 pub fn load_masked_m128d(a: &m128d, mask: m128i) -> m128d {
984 m128d(unsafe { _mm_maskload_pd(a as *const m128d as *const f64, mask.0) })
985 }
986
987 /// Load data from memory into a register according to a mask.
988 ///
989 /// When the high bit of a mask lane isn't set the loaded lane will be zero.
990 ///
991 /// * **Intrinsic:** [``]
992 /// * **Assembly:**
993 #[must_use]
994 #[inline(always)]
995 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
996 pub fn load_masked_m256d(a: &m256d, mask: m256i) -> m256d {
997 m256d(unsafe { _mm256_maskload_pd(a as *const m256d as *const f64, mask.0) })
998 }
999
1000 /// Load data from memory into a register according to a mask.
1001 ///
1002 /// When the high bit of a mask lane isn't set the loaded lane will be zero.
1003 ///
1004 /// * **Intrinsic:** [``]
1005 /// * **Assembly:**
1006 #[must_use]
1007 #[inline(always)]
1008 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1009 pub fn load_masked_m128(a: &m128, mask: m128i) -> m128 {
1010 m128(unsafe { _mm_maskload_ps(a as *const m128 as *const f32, mask.0) })
1011 }
1012
1013 /// Load data from memory into a register according to a mask.
1014 ///
1015 /// When the high bit of a mask lane isn't set the loaded lane will be zero.
1016 ///
1017 /// * **Intrinsic:** [``]
1018 /// * **Assembly:**
1019 #[must_use]
1020 #[inline(always)]
1021 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1022 pub fn load_masked_m256(a: &m256, mask: m256i) -> m256 {
1023 m256(unsafe { _mm256_maskload_ps(a as *const m256 as *const f32, mask.0) })
1024 }
1025
1026 /// Store data from a register into memory according to a mask.
1027 ///
1028 /// When the high bit of a mask lane isn't set that lane is not written.
1029 ///
1030 /// * **Intrinsic:** [``]
1031 /// * **Assembly:**
1032 #[inline(always)]
1033 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1034 pub fn store_masked_m128d(addr: &mut m128d, mask: m128i, a: m128d) {
1035 unsafe { _mm_maskstore_pd(addr as *mut m128d as *mut f64, mask.0, a.0) }
1036 }
1037
1038 /// Store data from a register into memory according to a mask.
1039 ///
1040 /// When the high bit of a mask lane isn't set that lane is not written.
1041 ///
1042 /// * **Intrinsic:** [``]
1043 /// * **Assembly:**
1044 #[inline(always)]
1045 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1046 pub fn store_masked_m256d(addr: &mut m256d, mask: m256i, a: m256d) {
1047 unsafe { _mm256_maskstore_pd(addr as *mut m256d as *mut f64, mask.0, a.0) }
1048 }
1049
1050 /// Store data from a register into memory according to a mask.
1051 ///
1052 /// When the high bit of a mask lane isn't set that lane is not written.
1053 ///
1054 /// * **Intrinsic:** [``]
1055 /// * **Assembly:**
1056 #[inline(always)]
1057 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1058 pub fn store_masked_m128(addr: &mut m128, mask: m128i, a: m128) {
1059 unsafe { _mm_maskstore_ps(addr as *mut m128 as *mut f32, mask.0, a.0) }
1060 }
1061
1062 /// Store data from a register into memory according to a mask.
1063 ///
1064 /// When the high bit of a mask lane isn't set that lane is not written.
1065 ///
1066 /// * **Intrinsic:** [``]
1067 /// * **Assembly:**
1068 #[inline(always)]
1069 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1070 pub fn store_masked_m256(addr: &mut m256, mask: m256i, a: m256) {
1071 unsafe { _mm256_maskstore_ps(addr as *mut m256 as *mut f32, mask.0, a.0) }
1072 }
1073
1074 /// Lanewise `max(a, b)`.
1075 ///
1076 /// * **Intrinsic:** [``]
1077 /// * **Assembly:**
1078 #[must_use]
1079 #[inline(always)]
1080 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1081 pub fn max_m256d(a: m256d, b: m256d) -> m256d {
1082 m256d(unsafe { _mm256_max_pd(a.0, b.0) })
1083 }
1084
1085 /// Lanewise `max(a, b)`.
1086 ///
1087 /// * **Intrinsic:** [``]
1088 /// * **Assembly:**
1089 #[must_use]
1090 #[inline(always)]
1091 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1092 pub fn max_m256(a: m256, b: m256) -> m256 {
1093 m256(unsafe { _mm256_max_ps(a.0, b.0) })
1094 }
1095
1096 /// Lanewise `min(a, b)`.
1097 ///
1098 /// * **Intrinsic:** [``]
1099 /// * **Assembly:**
1100 #[must_use]
1101 #[inline(always)]
1102 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1103 pub fn min_m256d(a: m256d, b: m256d) -> m256d {
1104 m256d(unsafe { _mm256_min_pd(a.0, b.0) })
1105 }
1106
1107 /// Lanewise `min(a, b)`.
1108 ///
1109 /// * **Intrinsic:** [``]
1110 /// * **Assembly:**
1111 #[must_use]
1112 #[inline(always)]
1113 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1114 pub fn min_m256(a: m256, b: m256) -> m256 {
1115 m256(unsafe { _mm256_min_ps(a.0, b.0) })
1116 }
1117
1118 /// Duplicate the odd-indexed lanes to the even lanes.
1119 ///
1120 /// * **Intrinsic:** [``]
1121 /// * **Assembly:**
1122 #[must_use]
1123 #[inline(always)]
1124 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1125 pub fn duplicate_odd_lanes_m256d(a: m256d) -> m256d {
1126 m256d(unsafe { _mm256_movedup_pd(a.0) })
1127 }
1128
1129 /// Duplicate the even-indexed lanes to the odd lanes.
1130 ///
1131 /// * **Intrinsic:** [``]
1132 /// * **Assembly:**
1133 #[must_use]
1134 #[inline(always)]
1135 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1136 pub fn duplicate_even_lanes_m256(a: m256) -> m256 {
1137 m256(unsafe { _mm256_movehdup_ps(a.0) })
1138 }
1139
1140 /// Duplicate the odd-indexed lanes to the even lanes.
1141 ///
1142 /// * **Intrinsic:** [``]
1143 /// * **Assembly:**
1144 #[must_use]
1145 #[inline(always)]
1146 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1147 pub fn duplicate_odd_lanes_m256(a: m256) -> m256 {
1148 m256(unsafe { _mm256_moveldup_ps(a.0) })
1149 }
1150
1151 /// Collects the sign bit of each lane into a 4-bit value.
1152 ///
1153 /// * **Intrinsic:** [``]
1154 /// * **Assembly:**
1155 #[must_use]
1156 #[inline(always)]
1157 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1158 pub fn move_mask_m256d(a: m256d) -> i32 {
1159 unsafe { _mm256_movemask_pd(a.0) }
1160 }
1161
1162 /// Computes the bitwise AND of 256 bits in `a` and
1163 /// `b`, returns 1 if the result is zero, otherwise 0.
1164 /// * **Intrinsic:** [`_mm256_testz_ps`]
1165 /// * **Assembly:** vtestps ymm, ymm
1166 #[must_use]
1167 #[inline(always)]
1168 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1169 pub fn testz_m256(a: m256, b: m256) -> i32 {
1170 unsafe { _mm256_testz_ps(a.0, b.0) }
1171 }
1172
1173 /// Computes the bitwise AND of 256 bits in `a` and
1174 /// `b`, returns 1 if the result is zero, otherwise 0.
1175 /// * **Intrinsic:** [`_mm_testz_ps`]
1176 /// * **Assembly:** vtestps xmm, xmm
1177 #[must_use]
1178 #[inline(always)]
1179 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1180 pub fn testz_m128(a: m128, b: m128) -> i32 {
1181 unsafe { _mm_testz_ps(a.0, b.0) }
1182 }
1183
1184 /// Compute the bitwise of sign bit NOT of `a` and then AND with `b`,
1185 /// returns 1 if the result is zero, otherwise 0.
1186 /// * **Intrinsic:** [`_mm256_testc_ps`]
1187 /// * **Assembly:** vtestps ymm, ymm
1188 #[must_use]
1189 #[inline(always)]
1190 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1191 pub fn testc_m256(a: m256, b: m256) -> i32 {
1192 unsafe { _mm256_testc_ps(a.0, b.0) }
1193 }
1194
1195 /// Compute the bitwise of sign bit NOT of `a` and then AND with `b`,
1196 /// returns 1 if the result is zero, otherwise 0.
1197 /// * **Intrinsic:** [`_mm_testc_ps`]
1198 /// * **Assembly:** vtestps xmm, xmm
1199 #[must_use]
1200 #[inline(always)]
1201 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1202 pub fn testc_m128(a: m128, b: m128) -> i32 {
1203 unsafe { _mm_testc_ps(a.0, b.0) }
1204 }
1205
1206 /// Computes the bitwise of sign bit AND of 256 bits in `a` and
1207 /// `b`, returns 1 if the result is zero, otherwise 0.
1208 /// * **Intrinsic:** [`_mm256_testz_pd`]
1209 /// * **Assembly:** vtestpd ymm, ymm
1210 #[must_use]
1211 #[inline(always)]
1212 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1213 pub fn testz_m256d(a: m256d, b: m256d) -> i32 {
1214 unsafe { _mm256_testz_pd(a.0, b.0) }
1215 }
1216
1217 /// Computes the bitwise of sign bitAND of 256 bits in `a` and
1218 /// `b`, returns 1 if the result is zero, otherwise 0.
1219 /// * **Intrinsic:** [`_mm_testz_pd`]
1220 /// * **Assembly:** vtestpd xmm, xmm
1221 #[must_use]
1222 #[inline(always)]
1223 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1224 pub fn testz_m128d(a: m128d, b: m128d) -> i32 {
1225 unsafe { _mm_testz_pd(a.0, b.0) }
1226 }
1227
1228 /// Compute the bitwise of sign bit NOT of `a` and then AND with `b`,
1229 /// returns 1 if the result is zero, otherwise 0.
1230 /// * **Intrinsic:** [`_mm256_testc_pd`]
1231 /// * **Assembly:** vtestpd ymm, ymm
1232 #[must_use]
1233 #[inline(always)]
1234 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1235 pub fn testc_m256d(a: m256d, b: m256d) -> i32 {
1236 unsafe { _mm256_testc_pd(a.0, b.0) }
1237 }
1238
1239 /// Compute the bitwise of sign bit NOT of `a` and then AND with `b`,
1240 /// returns 1 if the result is zero, otherwise 0.
1241 /// * **Intrinsic:** [`_mm_testc_si128`]
1242 /// * **Assembly:** vptest xmm, xmm
1243 #[must_use]
1244 #[inline(always)]
1245 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1246 pub fn testc_m128d(a: m128d, b: m128d) -> i32 {
1247 unsafe { _mm_testc_pd(a.0, b.0) }
1248 }
1249
1250 /// Computes the bitwise of sign bit AND of 256 bits in `a` and
1251 /// `b`, returns 1 if the result is zero, otherwise 0.
1252 /// * **Intrinsic:** [`_mm256_testz_si256`]
1253 /// * **Assembly:** vptest ymm, ymm
1254 #[must_use]
1255 #[inline(always)]
1256 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1257 pub fn testz_m256i(a: m256i, b: m256i) -> i32 {
1258 unsafe { _mm256_testz_si256(a.0, b.0) }
1259 }
1260
1261 /// Compute the bitwise NOT of `a` and then AND with `b`,
1262 /// returns 1 if the result is zero, otherwise 0.
1263 /// * **Intrinsic:** [`_mm256_testc_si256`]
1264 /// * **Assembly:** vptest ymm, ymm
1265 #[must_use]
1266 #[inline(always)]
1267 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1268 pub fn testc_m256i(a: m256i, b: m256i) -> i32 {
1269 unsafe { _mm256_testc_si256(a.0, b.0) }
1270 }
1271
1272 /// Collects the sign bit of each lane into a 4-bit value.
1273 ///
1274 /// * **Intrinsic:** [``]
1275 /// * **Assembly:**
1276 #[must_use]
1277 #[inline(always)]
1278 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1279 pub fn move_mask_m256(a: m256) -> i32 {
1280 unsafe { _mm256_movemask_ps(a.0) }
1281 }
1282
1283 /// Lanewise `a * b` with `f64` lanes.
1284 ///
1285 /// * **Intrinsic:** [``]
1286 /// * **Assembly:**
1287 #[must_use]
1288 #[inline(always)]
1289 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1290 pub fn mul_m256d(a: m256d, b: m256d) -> m256d {
1291 m256d(unsafe { _mm256_mul_pd(a.0, b.0) })
1292 }
1293
1294 /// Lanewise `a * b` with `f32` lanes.
1295 ///
1296 /// * **Intrinsic:** [``]
1297 /// * **Assembly:**
1298 #[must_use]
1299 #[inline(always)]
1300 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1301 pub fn mul_m256(a: m256, b: m256) -> m256 {
1302 m256(unsafe { _mm256_mul_ps(a.0, b.0) })
1303 }
1304
1305 /// Bitwise `a | b`.
1306 ///
1307 /// * **Intrinsic:** [``]
1308 /// * **Assembly:**
1309 #[must_use]
1310 #[inline(always)]
1311 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1312 pub fn bitor_m256d(a: m256d, b: m256d) -> m256d {
1313 m256d(unsafe { _mm256_or_pd(a.0, b.0) })
1314 }
1315
1316 /// Bitwise `a | b`.
1317 ///
1318 /// * **Intrinsic:** [``]
1319 /// * **Assembly:**
1320 #[must_use]
1321 #[inline(always)]
1322 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1323 pub fn bitor_m256(a: m256, b: m256) -> m256 {
1324 m256(unsafe { _mm256_or_ps(a.0, b.0) })
1325 }
1326
1327 /// Shuffle the `f64` lanes in `a` using an immediate control value.
1328 ///
1329 /// * **Intrinsic:** [`_mm_permute_pd`]
1330 /// * **Assembly:** `vpermilpd xmm, xmm, imm8`
1331 #[must_use]
1332 #[inline(always)]
1333 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1334 pub fn permute_m128d<const MASK: i32>(a: m128d) -> m128d {
1335 m128d(unsafe { _mm_permute_pd(a.0, MASK) })
1336 }
1337
1338 /// Shuffle the `f64` lanes from `a` together using an immediate
1339 /// control value.
1340 ///
1341 /// * **Intrinsic:** [`_mm256_permute_pd`]
1342 /// * **Assembly:** `vpermilpd ymm, ymm, imm8`
1343 #[must_use]
1344 #[inline(always)]
1345 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1346 pub fn permute_m256d<const MASK: i32>(a: m256d) -> m256d {
1347 m256d(unsafe { _mm256_permute_pd(a.0, MASK) })
1348 }
1349
1350 /// Shuffle the `f32` lanes from `a` using an immediate control value.
1351 ///
1352 /// * **Intrinsic:** [``]
1353 /// * **Assembly:**
1354 #[must_use]
1355 #[inline(always)]
1356 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1357 pub fn permute_m128<const MASK: i32>(a: m128) -> m128 {
1358 m128(unsafe { _mm_permute_ps(a.0, MASK) })
1359 }
1360
1361 /// Shuffle the `f32` lanes in `a` using an immediate control value.
1362 ///
1363 /// * **Intrinsic:** [`_mm256_permute_ps`]
1364 /// * **Assembly:** `vpermilps ymm, ymm, imm8`
1365 #[must_use]
1366 #[inline(always)]
1367 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1368 pub fn permute_m256<const MASK: i32>(a: m256) -> m256 {
1369 m256(unsafe { _mm256_permute_ps(a.0, MASK) })
1370 }
1371
1372 /// Shuffle 128 bits of floating point data at a time from `a` and `b` using an
1373 /// immediate control value.
1374 ///
1375 /// Each output selection is 4-bit wide, if `1000` is passed, that output is
1376 /// zeroed instead of picking from `a` or `b`.
1377 ///
1378 /// * **Intrinsic:** [`_mm256_permute2f128_pd`]
1379 /// * **Assembly:** `vperm2f128 ymm, ymm, ymm, imm8`
1380 #[must_use]
1381 #[inline(always)]
1382 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1383 pub fn permute2z_m256d<const MASK: i32>(a: m256d, b: m256d) -> m256d {
1384 m256d(unsafe { _mm256_permute2f128_pd(a.0, b.0, MASK) })
1385 }
1386
1387 /// Shuffle 128 bits of floating point data at a time from `$a` and `$b` using
1388 /// an immediate control value.
1389 ///
1390 /// Each output selection is 4-bit wide, if `1000` is passed, that output is
1391 /// zeroed instead of picking from `a` or `b`.
1392 ///
1393 /// * **Intrinsic:** [`_mm256_permute2f128_ps`]
1394 /// * **Assembly:** `vperm2f128 ymm, ymm, ymm, imm8`
1395 #[must_use]
1396 #[inline(always)]
1397 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1398 pub fn permute2z_m256<const MASK: i32>(a: m256, b: m256) -> m256 {
1399 m256(unsafe { _mm256_permute2f128_ps(a.0, b.0, MASK) })
1400 }
1401
1402 /// *Slowly* swizzle 128 bits of integer data from `a` and `b` using an
1403 /// immediate control value.
1404 ///
1405 /// Each output selection is 4-bit wide, if `1000` is passed, that output is
1406 /// zeroed instead of picking from `a` or `b`.
1407 ///
1408 /// If `avx2` is available you should use [`shuffle_abi_i128z_all_m256i`]
1409 /// instead. Only use this if you're targeting `avx` but not `avx2`.
1410 ///
1411 /// * **Intrinsic:** [`_mm256_permute2f128_si256`]
1412 /// * **Assembly:** `vperm2f128 ymm, ymm, ymm, imm8`
1413 #[must_use]
1414 #[inline(always)]
1415 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1416 pub fn permute2z_m256i<const MASK: i32>(a: m256i, b: m256i) -> m256i {
1417 m256i(unsafe { _mm256_permute2f128_si256(a.0, b.0, MASK) })
1418 }
1419
1420 /// Shuffle `f64` lanes in `a` using **bit 1** of the `i64` lanes in `v`
1421 ///
1422 /// * **Intrinsic:** [`_mm_permutevar_pd`]
1423 /// * **Assembly:** `vpermilpd xmm, xmm, xmm`
1424 #[must_use]
1425 #[inline(always)]
1426 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1427 pub fn shuffle_av_f64_all_m128d(a: m128d, v: m128i) -> m128d {
1428 m128d(unsafe { _mm_permutevar_pd(a.0, v.0) })
1429 }
1430
1431 /// Shuffle `f64` lanes in `a` using **bit 1** of the `i64` lanes in `v`.
1432 ///
1433 /// Each lane selection value picks only within that 128-bit half of the overall
1434 /// register.
1435 ///
1436 /// * **Intrinsic:** [`_mm256_permutevar_pd`]
1437 /// * **Assembly:** `vpermilpd ymm, ymm, ymm`
1438 #[must_use]
1439 #[inline(always)]
1440 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1441 pub fn shuffle_av_f64_half_m256d(a: m256d, b: m256i) -> m256d {
1442 m256d(unsafe { _mm256_permutevar_pd(a.0, b.0) })
1443 }
1444
1445 /// Shuffle `f32` values in `a` using `i32` values in `v`.
1446 ///
1447 /// * **Intrinsic:** [`_mm_permutevar_ps`]
1448 /// * **Assembly:** `vpermilps xmm, xmm, xmm`
1449 #[must_use]
1450 #[inline(always)]
1451 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1452 pub fn shuffle_av_f32_all_m128(a: m128, v: m128i) -> m128 {
1453 m128(unsafe { _mm_permutevar_ps(a.0, v.0) })
1454 }
1455
1456 /// Shuffle `f32` values in `a` using `i32` values in `v`.
1457 ///
1458 /// Each lane selection value picks only within that 128-bit half of the overall
1459 /// register.
1460 ///
1461 /// * **Intrinsic:** [`_mm256_permutevar_ps`]
1462 /// * **Assembly:** `vpermilps ymm, ymm, ymm`
1463 #[must_use]
1464 #[inline(always)]
1465 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1466 pub fn shuffle_av_f32_half_m256(a: m256, v: m256i) -> m256 {
1467 m256(unsafe { _mm256_permutevar_ps(a.0, v.0) })
1468 }
1469
1470 /// Reciprocal of `f32` lanes.
1471 ///
1472 /// * **Intrinsic:** [``]
1473 /// * **Assembly:**
1474 #[must_use]
1475 #[inline(always)]
1476 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1477 pub fn reciprocal_m256(a: m256) -> m256 {
1478 m256(unsafe { _mm256_rcp_ps(a.0) })
1479 }
1480
1481 /// Rounds each lane in the style specified.
1482 ///
1483 /// * **Intrinsic:** [``]
1484 /// * **Assembly:**
1485 #[must_use]
1486 #[inline(always)]
1487 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1488 pub fn round_m256d<const OP: i32>(a: m256d) -> m256d {
1489 m256d(unsafe { _mm256_round_pd(a.0, OP) })
1490 }
1491
1492 /// Rounds each lane in the style specified.
1493 ///
1494 /// * **Intrinsic:** [``]
1495 /// * **Assembly:**
1496 #[must_use]
1497 #[inline(always)]
1498 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1499 pub fn round_m256<const OP: i32>(a: m256) -> m256 {
1500 m256(unsafe { _mm256_round_ps(a.0, OP) })
1501 }
1502
1503 /// Reciprocal of `f32` lanes.
1504 ///
1505 /// * **Intrinsic:** [``]
1506 /// * **Assembly:**
1507 #[must_use]
1508 #[inline(always)]
1509 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1510 pub fn reciprocal_sqrt_m256(a: m256) -> m256 {
1511 m256(unsafe { _mm256_rsqrt_ps(a.0) })
1512 }
1513
1514 /// Set `i8` args into an `m256i` lane.
1515 ///
1516 /// * **Intrinsic:** [``]
1517 /// * **Assembly:**
1518 #[must_use]
1519 #[inline(always)]
1520 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1521 #[rustfmt::skip]
1522 pub fn set_i8_m256i(
1523 e31: i8, e30: i8, e29: i8, e28: i8, e27: i8, e26: i8, e25: i8, e24: i8, e23: i8, e22: i8, e21: i8, e20: i8, e19: i8, e18: i8, e17: i8, e16: i8, e15: i8, e14: i8, e13: i8, e12: i8, e11: i8, e10: i8, e9: i8, e8: i8, e7: i8, e6: i8, e5: i8, e4: i8, e3: i8, e2: i8, e1: i8, e0: i8
1524 ) -> m256i {
1525 m256i(unsafe {
1526 _mm256_set_epi8(
1527 e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0
1528 )
1529 })
1530 }
1531
1532 /// Set `i16` args into an `m256i` lane.
1533 ///
1534 /// * **Intrinsic:** [``]
1535 /// * **Assembly:**
1536 #[must_use]
1537 #[inline(always)]
1538 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1539 #[rustfmt::skip]
1540 pub fn set_i16_m256i(
1541 e15: i16, e14: i16, e13: i16, e12: i16, e11: i16, e10: i16, e9: i16, e8: i16,
1542 e7: i16, e6: i16, e5: i16, e4: i16, e3: i16, e2: i16, e1: i16, e0: i16,
1543 ) -> m256i {
1544 m256i(unsafe {
1545 _mm256_set_epi16(
1546 e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0,
1547 )
1548 })
1549 }
1550
1551 /// Set `i32` args into an `m256i` lane.
1552 ///
1553 /// * **Intrinsic:** [``]
1554 /// * **Assembly:**
1555 #[must_use]
1556 #[inline(always)]
1557 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1558 #[rustfmt::skip]
1559 pub fn set_i32_m256i(
1560 e7: i32, e6: i32, e5: i32, e4: i32, e3: i32, e2: i32, e1: i32, e0: i32,
1561 ) -> m256i {
1562 m256i(unsafe {
1563 _mm256_set_epi32(e7, e6, e5, e4, e3, e2, e1, e0)
1564 })
1565 }
1566
1567 /// Set `i64` args into an `m256i` lane.
1568 ///
1569 /// * **Intrinsic:** [``]
1570 /// * **Assembly:**
1571 #[must_use]
1572 #[inline(always)]
1573 #[cfg(target_arch = "x86_64")]
1574 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1575 pub fn set_i64_m256i(e3: i64, e2: i64, e1: i64, e0: i64) -> m256i {
1576 m256i(unsafe { _mm256_set_epi64x(e3, e2, e1, e0) })
1577 }
1578
1579 /// Set `m128` args into an `m256`.
1580 ///
1581 /// * **Intrinsic:** [``]
1582 /// * **Assembly:**
1583 #[must_use]
1584 #[inline(always)]
1585 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1586 pub fn set_m128_m256(high: m128, low: m128) -> m256 {
1587 m256(unsafe { _mm256_set_m128(high.0, low.0) })
1588 }
1589
1590 /// Set `m128d` args into an `m256d`.
1591 ///
1592 /// * **Intrinsic:** [``]
1593 /// * **Assembly:**
1594 #[must_use]
1595 #[inline(always)]
1596 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1597 #[rustfmt::skip]
1598 pub fn set_m128d_m256d(
1599 high: m128d, low: m128d
1600 ) -> m256d {
1601 m256d(unsafe { _mm256_set_m128d(high.0, low.0) })
1602 }
1603
1604 /// Set `m128i` args into an `m256i`.
1605 ///
1606 /// * **Intrinsic:** [``]
1607 /// * **Assembly:**
1608 #[must_use]
1609 #[inline(always)]
1610 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1611 #[rustfmt::skip]
1612 pub fn set_m128i_m256i(
1613 hi: m128i, lo: m128i
1614 ) -> m256i {
1615 m256i(unsafe { _mm256_set_m128i(hi.0, lo.0) })
1616 }
1617
1618 /// Set `f64` args into an `m256d` lane.
1619 ///
1620 /// * **Intrinsic:** [``]
1621 /// * **Assembly:**
1622 #[must_use]
1623 #[inline(always)]
1624 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1625 #[rustfmt::skip]
1626 pub fn set_m256d(
1627 e3: f64, e2: f64, e1: f64, e0: f64,
1628 ) -> m256d {
1629 m256d(unsafe { _mm256_set_pd(e3, e2, e1, e0) })
1630 }
1631
1632 /// Set `f32` args into an `m256` lane.
1633 ///
1634 /// * **Intrinsic:** [``]
1635 /// * **Assembly:**
1636 #[must_use]
1637 #[inline(always)]
1638 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1639 #[rustfmt::skip]
1640 pub fn set_m256(
1641 e7: f32, e6: f32, e5: f32, e4: f32, e3: f32, e2: f32, e1: f32, e0: f32,
1642 ) -> m256 {
1643 m256(unsafe {
1644 _mm256_set_ps(e7, e6, e5, e4, e3, e2, e1, e0)
1645 })
1646 }
1647
1648 /// Splat an `i8` arg into an `m256i` lane.
1649 ///
1650 /// * **Intrinsic:** [``]
1651 /// * **Assembly:**
1652 #[must_use]
1653 #[inline(always)]
1654 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1655 pub fn set_splat_i8_m256i(i: i8) -> m256i {
1656 m256i(unsafe { _mm256_set1_epi8(i) })
1657 }
1658
1659 /// Splat an `i16` arg into an `m256i` lane.
1660 ///
1661 /// * **Intrinsic:** [``]
1662 /// * **Assembly:**
1663 #[must_use]
1664 #[inline(always)]
1665 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1666 pub fn set_splat_i16_m256i(i: i16) -> m256i {
1667 m256i(unsafe { _mm256_set1_epi16(i) })
1668 }
1669
1670 /// Splat an `i32` arg into an `m256i` lane.
1671 ///
1672 /// * **Intrinsic:** [``]
1673 /// * **Assembly:**
1674 #[must_use]
1675 #[inline(always)]
1676 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1677 pub fn set_splat_i32_m256i(i: i32) -> m256i {
1678 m256i(unsafe { _mm256_set1_epi32(i) })
1679 }
1680
1681 /// Splat an `i64` arg into an `m256i` lane.
1682 ///
1683 /// * **Intrinsic:** [``]
1684 /// * **Assembly:**
1685 #[must_use]
1686 #[inline(always)]
1687 #[cfg(target_arch = "x86_64")]
1688 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1689 pub fn set_splat_i64_m256i(i: i64) -> m256i {
1690 m256i(unsafe { _mm256_set1_epi64x(i) })
1691 }
1692
1693 /// Splat an `f64` arg into an `m256d` lane.
1694 ///
1695 /// * **Intrinsic:** [``]
1696 /// * **Assembly:**
1697 #[must_use]
1698 #[inline(always)]
1699 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1700 pub fn set_splat_m256d(f: f64) -> m256d {
1701 m256d(unsafe { _mm256_set1_pd(f) })
1702 }
1703
1704 /// Splat an `f32` arg into an `m256` lane.
1705 ///
1706 /// * **Intrinsic:** [``]
1707 /// * **Assembly:**
1708 #[must_use]
1709 #[inline(always)]
1710 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1711 #[rustfmt::skip]
1712 pub fn set_splat_m256(
1713 f: f32,
1714 ) -> m256 {
1715 m256(unsafe {
1716 _mm256_set1_ps(f)
1717 })
1718 }
1719
1720 /// Set `i8` args into an `m256i` lane.
1721 ///
1722 /// * **Intrinsic:** [``]
1723 /// * **Assembly:**
1724 #[must_use]
1725 #[inline(always)]
1726 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1727 #[rustfmt::skip]
1728 pub fn set_reversed_i8_m256i(
1729 e31: i8, e30: i8, e29: i8, e28: i8, e27: i8, e26: i8, e25: i8, e24: i8, e23: i8, e22: i8, e21: i8, e20: i8, e19: i8, e18: i8, e17: i8, e16: i8, e15: i8, e14: i8, e13: i8, e12: i8, e11: i8, e10: i8, e9: i8, e8: i8, e7: i8, e6: i8, e5: i8, e4: i8, e3: i8, e2: i8, e1: i8, e0: i8
1730 ) -> m256i {
1731 m256i(unsafe {
1732 _mm256_setr_epi8(
1733 e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0
1734 )
1735 })
1736 }
1737
1738 /// Set `i16` args into an `m256i` lane.
1739 ///
1740 /// * **Intrinsic:** [``]
1741 /// * **Assembly:**
1742 #[must_use]
1743 #[inline(always)]
1744 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1745 #[rustfmt::skip]
1746 pub fn set_reversed_i16_m256i(
1747 e15: i16, e14: i16, e13: i16, e12: i16, e11: i16, e10: i16, e9: i16, e8: i16,
1748 e7: i16, e6: i16, e5: i16, e4: i16, e3: i16, e2: i16, e1: i16, e0: i16,
1749 ) -> m256i {
1750 m256i(unsafe {
1751 _mm256_setr_epi16(
1752 e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0,
1753 )
1754 })
1755 }
1756
1757 /// Set `i32` args into an `m256i` lane.
1758 ///
1759 /// * **Intrinsic:** [``]
1760 /// * **Assembly:**
1761 #[must_use]
1762 #[inline(always)]
1763 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1764 #[rustfmt::skip]
1765 pub fn set_reversed_i32_m256i(
1766 e7: i32, e6: i32, e5: i32, e4: i32, e3: i32, e2: i32, e1: i32, e0: i32,
1767 ) -> m256i {
1768 m256i(unsafe {
1769 _mm256_setr_epi32(e7, e6, e5, e4, e3, e2, e1, e0)
1770 })
1771 }
1772
1773 /// Set `i64` args into an `m256i` lane.
1774 ///
1775 /// * **Intrinsic:** [``]
1776 /// * **Assembly:**
1777 #[must_use]
1778 #[inline(always)]
1779 #[cfg(target_arch = "x86_64")]
1780 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1781 pub fn set_reversed_i64_m256i(e3: i64, e2: i64, e1: i64, e0: i64) -> m256i {
1782 m256i(unsafe { _mm256_setr_epi64x(e3, e2, e1, e0) })
1783 }
1784
1785 /// Set `m128` args into an `m256`.
1786 ///
1787 /// * **Intrinsic:** [``]
1788 /// * **Assembly:**
1789 #[must_use]
1790 #[inline(always)]
1791 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1792 pub fn set_reversed_m128_m256(hi: m128, lo: m128) -> m256 {
1793 m256(unsafe { _mm256_setr_m128(hi.0, lo.0) })
1794 }
1795
1796 /// Set `m128d` args into an `m256d`.
1797 ///
1798 /// * **Intrinsic:** [``]
1799 /// * **Assembly:**
1800 #[must_use]
1801 #[inline(always)]
1802 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1803 #[rustfmt::skip]
1804 pub fn set_reversed_m128d_m256d(
1805 hi: m128d, lo: m128d
1806 ) -> m256d {
1807 m256d(unsafe { _mm256_setr_m128d(hi.0, lo.0) })
1808 }
1809
1810 /// Set `m128i` args into an `m256i`.
1811 ///
1812 /// * **Intrinsic:** [``]
1813 /// * **Assembly:**
1814 #[must_use]
1815 #[inline(always)]
1816 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1817 #[rustfmt::skip]
1818 pub fn set_reversed_m128i_m256i(
1819 hi: m128i, lo: m128i
1820 ) -> m256i {
1821 m256i(unsafe { _mm256_setr_m128i(hi.0, lo.0) })
1822 }
1823
1824 /// Set `f64` args into an `m256d` lane.
1825 ///
1826 /// * **Intrinsic:** [``]
1827 /// * **Assembly:**
1828 #[must_use]
1829 #[inline(always)]
1830 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1831 #[rustfmt::skip]
1832 pub fn set_reversed_m256d(
1833 e3: f64, e2: f64, e1: f64, e0: f64,
1834 ) -> m256d {
1835 m256d(unsafe { _mm256_setr_pd(e3, e2, e1, e0) })
1836 }
1837
1838 /// Set `f32` args into an `m256` lane.
1839 ///
1840 /// * **Intrinsic:** [``]
1841 /// * **Assembly:**
1842 #[must_use]
1843 #[inline(always)]
1844 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1845 #[rustfmt::skip]
1846 pub fn set_reversed_m256(
1847 e7: f32, e6: f32, e5: f32, e4: f32, e3: f32, e2: f32, e1: f32, e0: f32,
1848 ) -> m256 {
1849 m256(unsafe {
1850 _mm256_setr_ps(e7, e6, e5, e4, e3, e2, e1, e0)
1851 })
1852 }
1853
1854 /// A zeroed `m256d`
1855 ///
1856 /// * **Intrinsic:** [``]
1857 /// * **Assembly:**
1858 #[must_use]
1859 #[inline(always)]
1860 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1861 pub fn zeroed_m256d() -> m256d {
1862 m256d(unsafe { _mm256_setzero_pd() })
1863 }
1864
1865 /// A zeroed `m256`
1866 ///
1867 /// * **Intrinsic:** [``]
1868 /// * **Assembly:**
1869 #[must_use]
1870 #[inline(always)]
1871 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1872 pub fn zeroed_m256() -> m256 {
1873 m256(unsafe { _mm256_setzero_ps() })
1874 }
1875
1876 /// A zeroed `m256i`
1877 ///
1878 /// * **Intrinsic:** [``]
1879 /// * **Assembly:**
1880 #[must_use]
1881 #[inline(always)]
1882 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1883 pub fn zeroed_m256i() -> m256i {
1884 m256i(unsafe { _mm256_setzero_si256() })
1885 }
1886
1887 /// Shuffle the `f64` lanes from `a` and `b` together using an immediate control
1888 /// value.
1889 ///
1890 /// The control value uses the lowest 4 bits only.
1891 /// * bit 0 picks between lanes 0 or 1 from A.
1892 /// * bit 1 picks between lanes 0 or 1 from B.
1893 /// * bit 2 picks between lanes 2 or 3 from A.
1894 /// * bit 3 picks between lanes 2 or 3 from B.
1895 ///
1896 /// Note that this shuffle cannot move data between the lower half of the lanes
1897 /// and the upper half of the lanes.
1898 ///
1899 /// * **Intrinsic:** [`_mm256_shuffle_pd`]
1900 /// * **Assembly:** `vshufpd ymm, ymm, ymm, imm8`
1901 #[must_use]
1902 #[inline(always)]
1903 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1904 pub fn shuffle_m256d<const IMM: i32>(a: m256d, b: m256d) -> m256d {
1905 m256d(unsafe { _mm256_shuffle_pd(a.0, b.0, IMM) })
1906 }
1907
1908 /// Shuffle the `f32` lanes from `a` and `b` together using an immediate
1909 /// control value.
1910 ///
1911 /// This works like [`shuffle_abi_f32_all_m128`], but with the low 128 bits and
1912 /// high 128 bits each doing a shuffle at the same time. Each index (`0..=3`)
1913 /// only refers to a lane within a given 128 bit portion of the 256 bit inputs.
1914 /// You cannot cross data between the two 128 bit halves.
1915 ///
1916 /// * **Intrinsic:** [`_mm256_shuffle_ps`]
1917 /// * **Assembly:** `vshufps ymm, ymm, ymm, imm8`
1918 #[must_use]
1919 #[inline(always)]
1920 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1921 pub fn shuffle_m256<const IMM: i32>(a: m256, b: m256) -> m256 {
1922 m256(unsafe { _mm256_shuffle_ps(a.0, b.0, IMM) })
1923 }
1924
1925 /// Lanewise `sqrt` on `f64` lanes.
1926 ///
1927 /// * **Intrinsic:** [``]
1928 /// * **Assembly:**
1929 #[must_use]
1930 #[inline(always)]
1931 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1932 pub fn sqrt_m256d(a: m256d) -> m256d {
1933 m256d(unsafe { _mm256_sqrt_pd(a.0) })
1934 }
1935
1936 /// Lanewise `sqrt` on `f64` lanes.
1937 ///
1938 /// * **Intrinsic:** [``]
1939 /// * **Assembly:**
1940 #[must_use]
1941 #[inline(always)]
1942 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1943 pub fn sqrt_m256(a: m256) -> m256 {
1944 m256(unsafe { _mm256_sqrt_ps(a.0) })
1945 }
1946
1947 /// Store data from a register into memory.
1948 ///
1949 /// * **Intrinsic:** [``]
1950 /// * **Assembly:**
1951 #[inline(always)]
1952 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1953 pub fn store_m256d(addr: &mut m256d, a: m256d) {
1954 unsafe { _mm256_store_pd(addr as *mut m256d as *mut f64, a.0) }
1955 }
1956
1957 /// Store data from a register into memory.
1958 ///
1959 /// * **Intrinsic:** [``]
1960 /// * **Assembly:**
1961 #[inline(always)]
1962 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1963 pub fn store_m256(addr: &mut m256, a: m256) {
1964 unsafe { _mm256_store_ps(addr as *mut m256 as *mut f32, a.0) }
1965 }
1966
1967 /// Store data from a register into memory.
1968 ///
1969 /// * **Intrinsic:** [``]
1970 /// * **Assembly:**
1971 #[inline(always)]
1972 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1973 pub fn store_m256i(addr: &mut m256i, a: m256i) {
1974 unsafe { _mm256_store_si256(addr as *mut m256i as *mut __m256i, a.0) }
1975 }
1976
1977 /// Store data from a register into memory.
1978 ///
1979 /// * **Intrinsic:** [``]
1980 /// * **Assembly:**
1981 #[inline(always)]
1982 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1983 pub fn store_unaligned_m256d(addr: &mut [f64; 4], a: m256d) {
1984 unsafe { _mm256_storeu_pd(addr.as_mut_ptr(), a.0) }
1985 }
1986
1987 /// Store data from a register into memory.
1988 ///
1989 /// * **Intrinsic:** [``]
1990 /// * **Assembly:**
1991 #[inline(always)]
1992 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
1993 pub fn store_unaligned_m256(addr: &mut [f32; 8], a: m256) {
1994 unsafe { _mm256_storeu_ps(addr.as_mut_ptr(), a.0) }
1995 }
1996
1997 /// Store data from a register into memory.
1998 ///
1999 /// * **Intrinsic:** [``]
2000 /// * **Assembly:**
2001 #[inline(always)]
2002 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2003 pub fn store_unaligned_m256i(addr: &mut [i8; 32], a: m256i) {
2004 unsafe { _mm256_storeu_si256(addr as *mut [i8; 32] as *mut __m256i, a.0) }
2005 }
2006
2007 /// Store data from a register into memory.
2008 ///
2009 /// * **Intrinsic:** [``]
2010 /// * **Assembly:**
2011 #[inline(always)]
2012 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2013 pub fn store_unaligned_hi_lo_m256d(hi_addr: &mut [f64; 2], lo_addr: &mut [f64; 2], a: m256d) {
2014 unsafe { _mm256_storeu2_m128d(hi_addr.as_mut_ptr(), lo_addr.as_mut_ptr(), a.0) }
2015 }
2016
2017 /// Store data from a register into memory.
2018 ///
2019 /// * **Intrinsic:** [``]
2020 /// * **Assembly:**
2021 #[inline(always)]
2022 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2023 pub fn store_unaligned_hi_lo_m256(hi_addr: &mut [f32; 4], lo_addr: &mut [f32; 4], a: m256) {
2024 unsafe { _mm256_storeu2_m128(hi_addr.as_mut_ptr(), lo_addr.as_mut_ptr(), a.0) }
2025 }
2026
2027 /// Store data from a register into memory.
2028 ///
2029 /// * **Intrinsic:** [``]
2030 /// * **Assembly:**
2031 #[inline(always)]
2032 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2033 pub fn store_unaligned_hi_lo_m256i(hi_addr: &mut [i8; 16], lo_addr: &mut [i8; 16], a: m256i) {
2034 unsafe { _mm256_storeu2_m128i(hi_addr.as_mut_ptr().cast(), lo_addr.as_mut_ptr().cast(), a.0) }
2035 }
2036
2037 /// Lanewise `a - b` with `f64` lanes.
2038 ///
2039 /// * **Intrinsic:** [``]
2040 /// * **Assembly:**
2041 #[must_use]
2042 #[inline(always)]
2043 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2044 pub fn sub_m256d(a: m256d, b: m256d) -> m256d {
2045 m256d(unsafe { _mm256_sub_pd(a.0, b.0) })
2046 }
2047
2048 /// Lanewise `a - b` with `f32` lanes.
2049 ///
2050 /// * **Intrinsic:** [``]
2051 /// * **Assembly:**
2052 #[must_use]
2053 #[inline(always)]
2054 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2055 pub fn sub_m256(a: m256, b: m256) -> m256 {
2056 m256(unsafe { _mm256_sub_ps(a.0, b.0) })
2057 }
2058
2059 /// Unpack and interleave the high lanes.
2060 ///
2061 /// * **Intrinsic:** [``]
2062 /// * **Assembly:**
2063 #[must_use]
2064 #[inline(always)]
2065 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2066 pub fn unpack_hi_m256d(a: m256d, b: m256d) -> m256d {
2067 m256d(unsafe { _mm256_unpackhi_pd(a.0, b.0) })
2068 }
2069
2070 /// Unpack and interleave the high lanes.
2071 ///
2072 /// * **Intrinsic:** [``]
2073 /// * **Assembly:**
2074 #[must_use]
2075 #[inline(always)]
2076 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2077 pub fn unpack_hi_m256(a: m256, b: m256) -> m256 {
2078 m256(unsafe { _mm256_unpackhi_ps(a.0, b.0) })
2079 }
2080
2081 /// Unpack and interleave the high lanes.
2082 ///
2083 /// * **Intrinsic:** [``]
2084 /// * **Assembly:**
2085 #[must_use]
2086 #[inline(always)]
2087 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2088 pub fn unpack_lo_m256d(a: m256d, b: m256d) -> m256d {
2089 m256d(unsafe { _mm256_unpacklo_pd(a.0, b.0) })
2090 }
2091
2092 /// Unpack and interleave the high lanes.
2093 ///
2094 /// * **Intrinsic:** [``]
2095 /// * **Assembly:**
2096 #[must_use]
2097 #[inline(always)]
2098 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2099 pub fn unpack_lo_m256(a: m256, b: m256) -> m256 {
2100 m256(unsafe { _mm256_unpacklo_ps(a.0, b.0) })
2101 }
2102
2103 /// Bitwise `a ^ b`.
2104 ///
2105 /// * **Intrinsic:** [``]
2106 /// * **Assembly:**
2107 #[must_use]
2108 #[inline(always)]
2109 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2110 pub fn bitxor_m256d(a: m256d, b: m256d) -> m256d {
2111 m256d(unsafe { _mm256_xor_pd(a.0, b.0) })
2112 }
2113
2114 /// Bitwise `a ^ b`.
2115 ///
2116 /// * **Intrinsic:** [``]
2117 /// * **Assembly:**
2118 #[must_use]
2119 #[inline(always)]
2120 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2121 pub fn bitxor_m256(a: m256, b: m256) -> m256 {
2122 m256(unsafe { _mm256_xor_ps(a.0, b.0) })
2123 }
2124
2125 /// Zero extend an `m128d` to `m256d`
2126 ///
2127 /// * **Intrinsic:** [``]
2128 /// * **Assembly:**
2129 #[must_use]
2130 #[inline(always)]
2131 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2132 pub fn zero_extend_m128d(a: m128d) -> m256d {
2133 m256d(unsafe { _mm256_zextpd128_pd256(a.0) })
2134 }
2135
2136 /// Zero extend an `m128` to `m256`
2137 ///
2138 /// * **Intrinsic:** [``]
2139 /// * **Assembly:**
2140 #[must_use]
2141 #[inline(always)]
2142 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2143 pub fn zero_extend_m128(a: m128) -> m256 {
2144 m256(unsafe { _mm256_zextps128_ps256(a.0) })
2145 }
2146
2147 /// Zero extend an `m128i` to `m256i`
2148 ///
2149 /// * **Intrinsic:** [``]
2150 /// * **Assembly:**
2151 #[must_use]
2152 #[inline(always)]
2153 #[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
2154 pub fn zero_extend_m128i(a: m128i) -> m256i {
2155 m256i(unsafe { _mm256_zextsi128_si256(a.0) })
2156 }
2157
2158 impl Add for m256d {
2159 type Output = Self;
2160 #[must_use]
2161 #[inline(always)]
2162 fn add(self, rhs: Self) -> Self {
2163 add_m256d(self, rhs)
2164 }
2165 }
2166 impl AddAssign for m256d {
2167 #[inline(always)]
2168 fn add_assign(&mut self, rhs: Self) {
2169 *self = *self + rhs;
2170 }
2171 }
2172
2173 impl BitAnd for m256d {
2174 type Output = Self;
2175 #[must_use]
2176 #[inline(always)]
2177 fn bitand(self, rhs: Self) -> Self {
2178 bitand_m256d(self, rhs)
2179 }
2180 }
2181 impl BitAndAssign for m256d {
2182 #[inline(always)]
2183 fn bitand_assign(&mut self, rhs: Self) {
2184 *self = *self & rhs;
2185 }
2186 }
2187
2188 impl BitOr for m256d {
2189 type Output = Self;
2190 #[must_use]
2191 #[inline(always)]
2192 fn bitor(self, rhs: Self) -> Self {
2193 bitor_m256d(self, rhs)
2194 }
2195 }
2196 impl BitOrAssign for m256d {
2197 #[inline(always)]
2198 fn bitor_assign(&mut self, rhs: Self) {
2199 *self = *self | rhs;
2200 }
2201 }
2202
2203 impl BitXor for m256d {
2204 type Output = Self;
2205 #[must_use]
2206 #[inline(always)]
2207 fn bitxor(self, rhs: Self) -> Self {
2208 bitxor_m256d(self, rhs)
2209 }
2210 }
2211 impl BitXorAssign for m256d {
2212 #[inline(always)]
2213 fn bitxor_assign(&mut self, rhs: Self) {
2214 *self = *self ^ rhs;
2215 }
2216 }
2217
2218 impl Div for m256d {
2219 type Output = Self;
2220 #[must_use]
2221 #[inline(always)]
2222 fn div(self, rhs: Self) -> Self {
2223 div_m256d(self, rhs)
2224 }
2225 }
2226 impl DivAssign for m256d {
2227 #[inline(always)]
2228 fn div_assign(&mut self, rhs: Self) {
2229 *self = *self / rhs;
2230 }
2231 }
2232
2233 impl Mul for m256d {
2234 type Output = Self;
2235 #[must_use]
2236 #[inline(always)]
2237 fn mul(self, rhs: Self) -> Self {
2238 mul_m256d(self, rhs)
2239 }
2240 }
2241 impl MulAssign for m256d {
2242 #[inline(always)]
2243 fn mul_assign(&mut self, rhs: Self) {
2244 *self = *self * rhs;
2245 }
2246 }
2247
2248 impl Neg for m256d {
2249 type Output = Self;
2250 #[must_use]
2251 #[inline(always)]
2252 fn neg(self) -> Self {
2253 sub_m256d(zeroed_m256d(), self)
2254 }
2255 }
2256
2257 impl Not for m256d {
2258 type Output = Self;
2259 /// Not a direct intrinsic, but it's very useful and the implementation is
2260 /// simple enough.
2261 ///
2262 /// Negates the bits by performing an `xor` with an all-ones bit pattern.
2263 #[must_use]
2264 #[inline(always)]
2265 fn not(self) -> Self {
2266 let all_bits = set_splat_m256d(f64::from_bits(u64::MAX));
2267 self ^ all_bits
2268 }
2269 }
2270
2271 impl Sub for m256d {
2272 type Output = Self;
2273 #[must_use]
2274 #[inline(always)]
2275 fn sub(self, rhs: Self) -> Self {
2276 sub_m256d(self, rhs)
2277 }
2278 }
2279 impl SubAssign for m256d {
2280 #[inline(always)]
2281 fn sub_assign(&mut self, rhs: Self) {
2282 *self = *self - rhs;
2283 }
2284 }
2285
2286 impl PartialEq for m256d {
2287 /// Performs a comparison to get a mask, then moves the mask and checks for
2288 /// all true.
2289 #[must_use]
2290 #[inline(always)]
2291 fn eq(&self, other: &Self) -> bool {
2292 let mask = m256d(unsafe { _mm256_cmp_pd(self.0, other.0, _CMP_EQ_OQ) });
2293 move_mask_m256d(mask) == 0b1111
2294 }
2295 }
2296
2297 impl Add for m256 {
2298 type Output = Self;
2299 #[must_use]
2300 #[inline(always)]
2301 fn add(self, rhs: Self) -> Self {
2302 add_m256(self, rhs)
2303 }
2304 }
2305 impl AddAssign for m256 {
2306 #[inline(always)]
2307 fn add_assign(&mut self, rhs: Self) {
2308 *self = *self + rhs;
2309 }
2310 }
2311
2312 impl BitAnd for m256 {
2313 type Output = Self;
2314 #[must_use]
2315 #[inline(always)]
2316 fn bitand(self, rhs: Self) -> Self {
2317 bitand_m256(self, rhs)
2318 }
2319 }
2320 impl BitAndAssign for m256 {
2321 #[inline(always)]
2322 fn bitand_assign(&mut self, rhs: Self) {
2323 *self = *self & rhs;
2324 }
2325 }
2326
2327 impl BitOr for m256 {
2328 type Output = Self;
2329 #[must_use]
2330 #[inline(always)]
2331 fn bitor(self, rhs: Self) -> Self {
2332 bitor_m256(self, rhs)
2333 }
2334 }
2335 impl BitOrAssign for m256 {
2336 #[inline(always)]
2337 fn bitor_assign(&mut self, rhs: Self) {
2338 *self = *self | rhs;
2339 }
2340 }
2341
2342 impl BitXor for m256 {
2343 type Output = Self;
2344 #[must_use]
2345 #[inline(always)]
2346 fn bitxor(self, rhs: Self) -> Self {
2347 bitxor_m256(self, rhs)
2348 }
2349 }
2350 impl BitXorAssign for m256 {
2351 #[inline(always)]
2352 fn bitxor_assign(&mut self, rhs: Self) {
2353 *self = *self ^ rhs;
2354 }
2355 }
2356
2357 impl Div for m256 {
2358 type Output = Self;
2359 #[must_use]
2360 #[inline(always)]
2361 fn div(self, rhs: Self) -> Self {
2362 div_m256(self, rhs)
2363 }
2364 }
2365 impl DivAssign for m256 {
2366 #[inline(always)]
2367 fn div_assign(&mut self, rhs: Self) {
2368 *self = *self / rhs;
2369 }
2370 }
2371
2372 impl Mul for m256 {
2373 type Output = Self;
2374 #[must_use]
2375 #[inline(always)]
2376 fn mul(self, rhs: Self) -> Self {
2377 mul_m256(self, rhs)
2378 }
2379 }
2380 impl MulAssign for m256 {
2381 #[inline(always)]
2382 fn mul_assign(&mut self, rhs: Self) {
2383 *self = *self * rhs;
2384 }
2385 }
2386
2387 impl Neg for m256 {
2388 type Output = Self;
2389 #[must_use]
2390 #[inline(always)]
2391 fn neg(self) -> Self {
2392 sub_m256(zeroed_m256(), self)
2393 }
2394 }
2395
2396 impl Not for m256 {
2397 type Output = Self;
2398 /// Not a direct intrinsic, but it's very useful and the implementation is
2399 /// simple enough.
2400 ///
2401 /// Negates the bits by performing an `xor` with an all-ones bit pattern.
2402 #[must_use]
2403 #[inline(always)]
2404 fn not(self) -> Self {
2405 let all_bits = set_splat_m256(f32::from_bits(u32::MAX));
2406 self ^ all_bits
2407 }
2408 }
2409
2410 impl Sub for m256 {
2411 type Output = Self;
2412 #[must_use]
2413 #[inline(always)]
2414 fn sub(self, rhs: Self) -> Self {
2415 sub_m256(self, rhs)
2416 }
2417 }
2418 impl SubAssign for m256 {
2419 #[inline(always)]
2420 fn sub_assign(&mut self, rhs: Self) {
2421 *self = *self - rhs;
2422 }
2423 }
2424
2425 impl PartialEq for m256 {
2426 /// Performs a comparison to get a mask, then moves the mask and checks for
2427 /// all true.
2428 #[must_use]
2429 #[inline(always)]
2430 fn eq(&self, other: &Self) -> bool {
2431 let mask = m256(unsafe { _mm256_cmp_ps(self.0, other.0, _CMP_EQ_OQ) });
2432 move_mask_m256(mask) == 0b1111_1111
2433 }
2434 }