1use crate::core_arch::{simd::*, x86::*};
22use crate::intrinsics::simd::*;
23
24#[cfg(test)]
25use stdarch_test::assert_instr;
26
27#[inline]
31#[target_feature(enable = "avx2")]
32#[cfg_attr(test, assert_instr(vpabsd))]
33#[stable(feature = "simd_x86", since = "1.27.0")]
34#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
35pub const fn _mm256_abs_epi32(a: __m256i) -> __m256i {
36 unsafe {
37 let a = a.as_i32x8();
38 let r = simd_select::<m32x8, _>(simd_lt(a, i32x8::ZERO), simd_neg(a), a);
39 transmute(r)
40 }
41}
42
43#[inline]
47#[target_feature(enable = "avx2")]
48#[cfg_attr(test, assert_instr(vpabsw))]
49#[stable(feature = "simd_x86", since = "1.27.0")]
50#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
51pub const fn _mm256_abs_epi16(a: __m256i) -> __m256i {
52 unsafe {
53 let a = a.as_i16x16();
54 let r = simd_select::<m16x16, _>(simd_lt(a, i16x16::ZERO), simd_neg(a), a);
55 transmute(r)
56 }
57}
58
59#[inline]
63#[target_feature(enable = "avx2")]
64#[cfg_attr(test, assert_instr(vpabsb))]
65#[stable(feature = "simd_x86", since = "1.27.0")]
66#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
67pub const fn _mm256_abs_epi8(a: __m256i) -> __m256i {
68 unsafe {
69 let a = a.as_i8x32();
70 let r = simd_select::<m8x32, _>(simd_lt(a, i8x32::ZERO), simd_neg(a), a);
71 transmute(r)
72 }
73}
74
75#[inline]
79#[target_feature(enable = "avx2")]
80#[cfg_attr(test, assert_instr(vpaddq))]
81#[stable(feature = "simd_x86", since = "1.27.0")]
82#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
83pub const fn _mm256_add_epi64(a: __m256i, b: __m256i) -> __m256i {
84 unsafe { transmute(simd_add(a.as_i64x4(), b.as_i64x4())) }
85}
86
87#[inline]
91#[target_feature(enable = "avx2")]
92#[cfg_attr(test, assert_instr(vpaddd))]
93#[stable(feature = "simd_x86", since = "1.27.0")]
94#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
95pub const fn _mm256_add_epi32(a: __m256i, b: __m256i) -> __m256i {
96 unsafe { transmute(simd_add(a.as_i32x8(), b.as_i32x8())) }
97}
98
99#[inline]
103#[target_feature(enable = "avx2")]
104#[cfg_attr(test, assert_instr(vpaddw))]
105#[stable(feature = "simd_x86", since = "1.27.0")]
106#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
107pub const fn _mm256_add_epi16(a: __m256i, b: __m256i) -> __m256i {
108 unsafe { transmute(simd_add(a.as_i16x16(), b.as_i16x16())) }
109}
110
111#[inline]
115#[target_feature(enable = "avx2")]
116#[cfg_attr(test, assert_instr(vpaddb))]
117#[stable(feature = "simd_x86", since = "1.27.0")]
118#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
119pub const fn _mm256_add_epi8(a: __m256i, b: __m256i) -> __m256i {
120 unsafe { transmute(simd_add(a.as_i8x32(), b.as_i8x32())) }
121}
122
123#[inline]
127#[target_feature(enable = "avx2")]
128#[cfg_attr(test, assert_instr(vpaddsb))]
129#[stable(feature = "simd_x86", since = "1.27.0")]
130#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
131pub const fn _mm256_adds_epi8(a: __m256i, b: __m256i) -> __m256i {
132 unsafe { transmute(simd_saturating_add(a.as_i8x32(), b.as_i8x32())) }
133}
134
135#[inline]
139#[target_feature(enable = "avx2")]
140#[cfg_attr(test, assert_instr(vpaddsw))]
141#[stable(feature = "simd_x86", since = "1.27.0")]
142#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
143pub const fn _mm256_adds_epi16(a: __m256i, b: __m256i) -> __m256i {
144 unsafe { transmute(simd_saturating_add(a.as_i16x16(), b.as_i16x16())) }
145}
146
147#[inline]
151#[target_feature(enable = "avx2")]
152#[cfg_attr(test, assert_instr(vpaddusb))]
153#[stable(feature = "simd_x86", since = "1.27.0")]
154#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
155pub const fn _mm256_adds_epu8(a: __m256i, b: __m256i) -> __m256i {
156 unsafe { transmute(simd_saturating_add(a.as_u8x32(), b.as_u8x32())) }
157}
158
159#[inline]
163#[target_feature(enable = "avx2")]
164#[cfg_attr(test, assert_instr(vpaddusw))]
165#[stable(feature = "simd_x86", since = "1.27.0")]
166#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
167pub const fn _mm256_adds_epu16(a: __m256i, b: __m256i) -> __m256i {
168 unsafe { transmute(simd_saturating_add(a.as_u16x16(), b.as_u16x16())) }
169}
170
171#[inline]
176#[target_feature(enable = "avx2")]
177#[cfg_attr(test, assert_instr(vpalignr, IMM8 = 7))]
178#[rustc_legacy_const_generics(2)]
179#[stable(feature = "simd_x86", since = "1.27.0")]
180#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
181pub const fn _mm256_alignr_epi8<const IMM8: i32>(a: __m256i, b: __m256i) -> __m256i {
182 static_assert_uimm_bits!(IMM8, 8);
183
184 if IMM8 >= 32 {
187 return _mm256_setzero_si256();
188 }
189 let (a, b) = if IMM8 > 16 {
192 (_mm256_setzero_si256(), a)
193 } else {
194 (a, b)
195 };
196 unsafe {
197 if IMM8 == 16 {
198 return transmute(a);
199 }
200 }
201 const fn mask(shift: u32, i: u32) -> u32 {
202 let shift = shift % 16;
203 let mod_i = i % 16;
204 if mod_i < (16 - shift) {
205 i + shift
206 } else {
207 i + 16 + shift
208 }
209 }
210
211 unsafe {
212 let r: i8x32 = simd_shuffle!(
213 b.as_i8x32(),
214 a.as_i8x32(),
215 [
216 mask(IMM8 as u32, 0),
217 mask(IMM8 as u32, 1),
218 mask(IMM8 as u32, 2),
219 mask(IMM8 as u32, 3),
220 mask(IMM8 as u32, 4),
221 mask(IMM8 as u32, 5),
222 mask(IMM8 as u32, 6),
223 mask(IMM8 as u32, 7),
224 mask(IMM8 as u32, 8),
225 mask(IMM8 as u32, 9),
226 mask(IMM8 as u32, 10),
227 mask(IMM8 as u32, 11),
228 mask(IMM8 as u32, 12),
229 mask(IMM8 as u32, 13),
230 mask(IMM8 as u32, 14),
231 mask(IMM8 as u32, 15),
232 mask(IMM8 as u32, 16),
233 mask(IMM8 as u32, 17),
234 mask(IMM8 as u32, 18),
235 mask(IMM8 as u32, 19),
236 mask(IMM8 as u32, 20),
237 mask(IMM8 as u32, 21),
238 mask(IMM8 as u32, 22),
239 mask(IMM8 as u32, 23),
240 mask(IMM8 as u32, 24),
241 mask(IMM8 as u32, 25),
242 mask(IMM8 as u32, 26),
243 mask(IMM8 as u32, 27),
244 mask(IMM8 as u32, 28),
245 mask(IMM8 as u32, 29),
246 mask(IMM8 as u32, 30),
247 mask(IMM8 as u32, 31),
248 ],
249 );
250 transmute(r)
251 }
252}
253
254#[inline]
259#[target_feature(enable = "avx2")]
260#[cfg_attr(test, assert_instr(vandps))]
261#[stable(feature = "simd_x86", since = "1.27.0")]
262#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
263pub const fn _mm256_and_si256(a: __m256i, b: __m256i) -> __m256i {
264 unsafe { transmute(simd_and(a.as_i64x4(), b.as_i64x4())) }
265}
266
267#[inline]
272#[target_feature(enable = "avx2")]
273#[cfg_attr(test, assert_instr(vandnps))]
274#[stable(feature = "simd_x86", since = "1.27.0")]
275#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
276pub const fn _mm256_andnot_si256(a: __m256i, b: __m256i) -> __m256i {
277 unsafe {
278 let all_ones = _mm256_set1_epi8(-1);
279 transmute(simd_and(
280 simd_xor(a.as_i64x4(), all_ones.as_i64x4()),
281 b.as_i64x4(),
282 ))
283 }
284}
285
286#[inline]
290#[target_feature(enable = "avx2")]
291#[cfg_attr(test, assert_instr(vpavgw))]
292#[stable(feature = "simd_x86", since = "1.27.0")]
293#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
294pub const fn _mm256_avg_epu16(a: __m256i, b: __m256i) -> __m256i {
295 unsafe {
296 let a = simd_cast::<_, u32x16>(a.as_u16x16());
297 let b = simd_cast::<_, u32x16>(b.as_u16x16());
298 let r = simd_shr(simd_add(simd_add(a, b), u32x16::splat(1)), u32x16::splat(1));
299 transmute(simd_cast::<_, u16x16>(r))
300 }
301}
302
303#[inline]
307#[target_feature(enable = "avx2")]
308#[cfg_attr(test, assert_instr(vpavgb))]
309#[stable(feature = "simd_x86", since = "1.27.0")]
310#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
311pub const fn _mm256_avg_epu8(a: __m256i, b: __m256i) -> __m256i {
312 unsafe {
313 let a = simd_cast::<_, u16x32>(a.as_u8x32());
314 let b = simd_cast::<_, u16x32>(b.as_u8x32());
315 let r = simd_shr(simd_add(simd_add(a, b), u16x32::splat(1)), u16x32::splat(1));
316 transmute(simd_cast::<_, u8x32>(r))
317 }
318}
319
320#[inline]
324#[target_feature(enable = "avx2")]
325#[cfg_attr(test, assert_instr(vblendps, IMM4 = 9))]
326#[rustc_legacy_const_generics(2)]
327#[stable(feature = "simd_x86", since = "1.27.0")]
328#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
329pub const fn _mm_blend_epi32<const IMM4: i32>(a: __m128i, b: __m128i) -> __m128i {
330 static_assert_uimm_bits!(IMM4, 4);
331 unsafe {
332 let a = a.as_i32x4();
333 let b = b.as_i32x4();
334 let r: i32x4 = simd_shuffle!(
335 a,
336 b,
337 [
338 [0, 4, 0, 4][IMM4 as usize & 0b11],
339 [1, 1, 5, 5][IMM4 as usize & 0b11],
340 [2, 6, 2, 6][(IMM4 as usize >> 2) & 0b11],
341 [3, 3, 7, 7][(IMM4 as usize >> 2) & 0b11],
342 ],
343 );
344 transmute(r)
345 }
346}
347
348#[inline]
352#[target_feature(enable = "avx2")]
353#[cfg_attr(test, assert_instr(vblendps, IMM8 = 9))]
354#[rustc_legacy_const_generics(2)]
355#[stable(feature = "simd_x86", since = "1.27.0")]
356#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
357pub const fn _mm256_blend_epi32<const IMM8: i32>(a: __m256i, b: __m256i) -> __m256i {
358 static_assert_uimm_bits!(IMM8, 8);
359 unsafe {
360 let a = a.as_i32x8();
361 let b = b.as_i32x8();
362 let r: i32x8 = simd_shuffle!(
363 a,
364 b,
365 [
366 [0, 8, 0, 8][IMM8 as usize & 0b11],
367 [1, 1, 9, 9][IMM8 as usize & 0b11],
368 [2, 10, 2, 10][(IMM8 as usize >> 2) & 0b11],
369 [3, 3, 11, 11][(IMM8 as usize >> 2) & 0b11],
370 [4, 12, 4, 12][(IMM8 as usize >> 4) & 0b11],
371 [5, 5, 13, 13][(IMM8 as usize >> 4) & 0b11],
372 [6, 14, 6, 14][(IMM8 as usize >> 6) & 0b11],
373 [7, 7, 15, 15][(IMM8 as usize >> 6) & 0b11],
374 ],
375 );
376 transmute(r)
377 }
378}
379
380#[inline]
384#[target_feature(enable = "avx2")]
385#[cfg_attr(test, assert_instr(vpblendw, IMM8 = 9))]
386#[rustc_legacy_const_generics(2)]
387#[stable(feature = "simd_x86", since = "1.27.0")]
388#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
389pub const fn _mm256_blend_epi16<const IMM8: i32>(a: __m256i, b: __m256i) -> __m256i {
390 static_assert_uimm_bits!(IMM8, 8);
391 unsafe {
392 let a = a.as_i16x16();
393 let b = b.as_i16x16();
394
395 let r: i16x16 = simd_shuffle!(
396 a,
397 b,
398 [
399 [0, 16, 0, 16][IMM8 as usize & 0b11],
400 [1, 1, 17, 17][IMM8 as usize & 0b11],
401 [2, 18, 2, 18][(IMM8 as usize >> 2) & 0b11],
402 [3, 3, 19, 19][(IMM8 as usize >> 2) & 0b11],
403 [4, 20, 4, 20][(IMM8 as usize >> 4) & 0b11],
404 [5, 5, 21, 21][(IMM8 as usize >> 4) & 0b11],
405 [6, 22, 6, 22][(IMM8 as usize >> 6) & 0b11],
406 [7, 7, 23, 23][(IMM8 as usize >> 6) & 0b11],
407 [8, 24, 8, 24][IMM8 as usize & 0b11],
408 [9, 9, 25, 25][IMM8 as usize & 0b11],
409 [10, 26, 10, 26][(IMM8 as usize >> 2) & 0b11],
410 [11, 11, 27, 27][(IMM8 as usize >> 2) & 0b11],
411 [12, 28, 12, 28][(IMM8 as usize >> 4) & 0b11],
412 [13, 13, 29, 29][(IMM8 as usize >> 4) & 0b11],
413 [14, 30, 14, 30][(IMM8 as usize >> 6) & 0b11],
414 [15, 15, 31, 31][(IMM8 as usize >> 6) & 0b11],
415 ],
416 );
417 transmute(r)
418 }
419}
420
421#[inline]
425#[target_feature(enable = "avx2")]
426#[cfg_attr(test, assert_instr(vpblendvb))]
427#[stable(feature = "simd_x86", since = "1.27.0")]
428#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
429pub const fn _mm256_blendv_epi8(a: __m256i, b: __m256i, mask: __m256i) -> __m256i {
430 unsafe {
431 let mask: i8x32 = simd_lt(mask.as_i8x32(), i8x32::ZERO);
432 transmute(simd_select(mask, b.as_i8x32(), a.as_i8x32()))
433 }
434}
435
436#[inline]
441#[target_feature(enable = "avx2")]
442#[cfg_attr(test, assert_instr(vpbroadcastb))]
443#[stable(feature = "simd_x86", since = "1.27.0")]
444#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
445pub const fn _mm_broadcastb_epi8(a: __m128i) -> __m128i {
446 unsafe {
447 let ret = simd_shuffle!(a.as_i8x16(), i8x16::ZERO, [0_u32; 16]);
448 transmute::<i8x16, _>(ret)
449 }
450}
451
452#[inline]
457#[target_feature(enable = "avx2")]
458#[cfg_attr(test, assert_instr(vpbroadcastb))]
459#[stable(feature = "simd_x86", since = "1.27.0")]
460#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
461pub const fn _mm256_broadcastb_epi8(a: __m128i) -> __m256i {
462 unsafe {
463 let ret = simd_shuffle!(a.as_i8x16(), i8x16::ZERO, [0_u32; 32]);
464 transmute::<i8x32, _>(ret)
465 }
466}
467
468#[inline]
475#[target_feature(enable = "avx2")]
476#[cfg_attr(test, assert_instr(vbroadcastss))]
477#[stable(feature = "simd_x86", since = "1.27.0")]
478#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
479pub const fn _mm_broadcastd_epi32(a: __m128i) -> __m128i {
480 unsafe {
481 let ret = simd_shuffle!(a.as_i32x4(), i32x4::ZERO, [0_u32; 4]);
482 transmute::<i32x4, _>(ret)
483 }
484}
485
486#[inline]
493#[target_feature(enable = "avx2")]
494#[cfg_attr(test, assert_instr(vbroadcastss))]
495#[stable(feature = "simd_x86", since = "1.27.0")]
496#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
497pub const fn _mm256_broadcastd_epi32(a: __m128i) -> __m256i {
498 unsafe {
499 let ret = simd_shuffle!(a.as_i32x4(), i32x4::ZERO, [0_u32; 8]);
500 transmute::<i32x8, _>(ret)
501 }
502}
503
504#[inline]
509#[target_feature(enable = "avx2")]
510#[cfg_attr(test, assert_instr(vmovddup))]
513#[stable(feature = "simd_x86", since = "1.27.0")]
514#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
515pub const fn _mm_broadcastq_epi64(a: __m128i) -> __m128i {
516 unsafe {
517 let ret = simd_shuffle!(a.as_i64x2(), a.as_i64x2(), [0_u32; 2]);
518 transmute::<i64x2, _>(ret)
519 }
520}
521
522#[inline]
527#[target_feature(enable = "avx2")]
528#[cfg_attr(test, assert_instr(vbroadcastsd))]
529#[stable(feature = "simd_x86", since = "1.27.0")]
530#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
531pub const fn _mm256_broadcastq_epi64(a: __m128i) -> __m256i {
532 unsafe {
533 let ret = simd_shuffle!(a.as_i64x2(), a.as_i64x2(), [0_u32; 4]);
534 transmute::<i64x4, _>(ret)
535 }
536}
537
538#[inline]
543#[target_feature(enable = "avx2")]
544#[cfg_attr(test, assert_instr(vmovddup))]
545#[stable(feature = "simd_x86", since = "1.27.0")]
546#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
547pub const fn _mm_broadcastsd_pd(a: __m128d) -> __m128d {
548 unsafe { simd_shuffle!(a, _mm_setzero_pd(), [0_u32; 2]) }
549}
550
551#[inline]
556#[target_feature(enable = "avx2")]
557#[cfg_attr(test, assert_instr(vbroadcastsd))]
558#[stable(feature = "simd_x86", since = "1.27.0")]
559#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
560pub const fn _mm256_broadcastsd_pd(a: __m128d) -> __m256d {
561 unsafe { simd_shuffle!(a, _mm_setzero_pd(), [0_u32; 4]) }
562}
563
564#[inline]
569#[target_feature(enable = "avx2")]
570#[stable(feature = "simd_x86_updates", since = "1.82.0")]
571#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
572pub const fn _mm_broadcastsi128_si256(a: __m128i) -> __m256i {
573 unsafe {
574 let ret = simd_shuffle!(a.as_i64x2(), i64x2::ZERO, [0, 1, 0, 1]);
575 transmute::<i64x4, _>(ret)
576 }
577}
578
579#[inline]
586#[target_feature(enable = "avx2")]
587#[stable(feature = "simd_x86", since = "1.27.0")]
588#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
589pub const fn _mm256_broadcastsi128_si256(a: __m128i) -> __m256i {
590 unsafe {
591 let ret = simd_shuffle!(a.as_i64x2(), i64x2::ZERO, [0, 1, 0, 1]);
592 transmute::<i64x4, _>(ret)
593 }
594}
595
596#[inline]
601#[target_feature(enable = "avx2")]
602#[cfg_attr(test, assert_instr(vbroadcastss))]
603#[stable(feature = "simd_x86", since = "1.27.0")]
604#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
605pub const fn _mm_broadcastss_ps(a: __m128) -> __m128 {
606 unsafe { simd_shuffle!(a, _mm_setzero_ps(), [0_u32; 4]) }
607}
608
609#[inline]
614#[target_feature(enable = "avx2")]
615#[cfg_attr(test, assert_instr(vbroadcastss))]
616#[stable(feature = "simd_x86", since = "1.27.0")]
617#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
618pub const fn _mm256_broadcastss_ps(a: __m128) -> __m256 {
619 unsafe { simd_shuffle!(a, _mm_setzero_ps(), [0_u32; 8]) }
620}
621
622#[inline]
627#[target_feature(enable = "avx2")]
628#[cfg_attr(test, assert_instr(vpbroadcastw))]
629#[stable(feature = "simd_x86", since = "1.27.0")]
630#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
631pub const fn _mm_broadcastw_epi16(a: __m128i) -> __m128i {
632 unsafe {
633 let ret = simd_shuffle!(a.as_i16x8(), i16x8::ZERO, [0_u32; 8]);
634 transmute::<i16x8, _>(ret)
635 }
636}
637
638#[inline]
643#[target_feature(enable = "avx2")]
644#[cfg_attr(test, assert_instr(vpbroadcastw))]
645#[stable(feature = "simd_x86", since = "1.27.0")]
646#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
647pub const fn _mm256_broadcastw_epi16(a: __m128i) -> __m256i {
648 unsafe {
649 let ret = simd_shuffle!(a.as_i16x8(), i16x8::ZERO, [0_u32; 16]);
650 transmute::<i16x16, _>(ret)
651 }
652}
653
654#[inline]
658#[target_feature(enable = "avx2")]
659#[cfg_attr(test, assert_instr(vpcmpeqq))]
660#[stable(feature = "simd_x86", since = "1.27.0")]
661#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
662pub const fn _mm256_cmpeq_epi64(a: __m256i, b: __m256i) -> __m256i {
663 unsafe { transmute::<i64x4, _>(simd_eq(a.as_i64x4(), b.as_i64x4())) }
664}
665
666#[inline]
670#[target_feature(enable = "avx2")]
671#[cfg_attr(test, assert_instr(vpcmpeqd))]
672#[stable(feature = "simd_x86", since = "1.27.0")]
673#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
674pub const fn _mm256_cmpeq_epi32(a: __m256i, b: __m256i) -> __m256i {
675 unsafe { transmute::<i32x8, _>(simd_eq(a.as_i32x8(), b.as_i32x8())) }
676}
677
678#[inline]
682#[target_feature(enable = "avx2")]
683#[cfg_attr(test, assert_instr(vpcmpeqw))]
684#[stable(feature = "simd_x86", since = "1.27.0")]
685#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
686pub const fn _mm256_cmpeq_epi16(a: __m256i, b: __m256i) -> __m256i {
687 unsafe { transmute::<i16x16, _>(simd_eq(a.as_i16x16(), b.as_i16x16())) }
688}
689
690#[inline]
694#[target_feature(enable = "avx2")]
695#[cfg_attr(test, assert_instr(vpcmpeqb))]
696#[stable(feature = "simd_x86", since = "1.27.0")]
697#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
698pub const fn _mm256_cmpeq_epi8(a: __m256i, b: __m256i) -> __m256i {
699 unsafe { transmute::<i8x32, _>(simd_eq(a.as_i8x32(), b.as_i8x32())) }
700}
701
702#[inline]
706#[target_feature(enable = "avx2")]
707#[cfg_attr(test, assert_instr(vpcmpgtq))]
708#[stable(feature = "simd_x86", since = "1.27.0")]
709#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
710pub const fn _mm256_cmpgt_epi64(a: __m256i, b: __m256i) -> __m256i {
711 unsafe { transmute::<i64x4, _>(simd_gt(a.as_i64x4(), b.as_i64x4())) }
712}
713
714#[inline]
718#[target_feature(enable = "avx2")]
719#[cfg_attr(test, assert_instr(vpcmpgtd))]
720#[stable(feature = "simd_x86", since = "1.27.0")]
721#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
722pub const fn _mm256_cmpgt_epi32(a: __m256i, b: __m256i) -> __m256i {
723 unsafe { transmute::<i32x8, _>(simd_gt(a.as_i32x8(), b.as_i32x8())) }
724}
725
726#[inline]
730#[target_feature(enable = "avx2")]
731#[cfg_attr(test, assert_instr(vpcmpgtw))]
732#[stable(feature = "simd_x86", since = "1.27.0")]
733#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
734pub const fn _mm256_cmpgt_epi16(a: __m256i, b: __m256i) -> __m256i {
735 unsafe { transmute::<i16x16, _>(simd_gt(a.as_i16x16(), b.as_i16x16())) }
736}
737
738#[inline]
742#[target_feature(enable = "avx2")]
743#[cfg_attr(test, assert_instr(vpcmpgtb))]
744#[stable(feature = "simd_x86", since = "1.27.0")]
745#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
746pub const fn _mm256_cmpgt_epi8(a: __m256i, b: __m256i) -> __m256i {
747 unsafe { transmute::<i8x32, _>(simd_gt(a.as_i8x32(), b.as_i8x32())) }
748}
749
750#[inline]
754#[target_feature(enable = "avx2")]
755#[cfg_attr(test, assert_instr(vpmovsxwd))]
756#[stable(feature = "simd_x86", since = "1.27.0")]
757#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
758pub const fn _mm256_cvtepi16_epi32(a: __m128i) -> __m256i {
759 unsafe { transmute::<i32x8, _>(simd_cast(a.as_i16x8())) }
760}
761
762#[inline]
766#[target_feature(enable = "avx2")]
767#[cfg_attr(test, assert_instr(vpmovsxwq))]
768#[stable(feature = "simd_x86", since = "1.27.0")]
769#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
770pub const fn _mm256_cvtepi16_epi64(a: __m128i) -> __m256i {
771 unsafe {
772 let a = a.as_i16x8();
773 let v64: i16x4 = simd_shuffle!(a, a, [0, 1, 2, 3]);
774 transmute::<i64x4, _>(simd_cast(v64))
775 }
776}
777
778#[inline]
782#[target_feature(enable = "avx2")]
783#[cfg_attr(test, assert_instr(vpmovsxdq))]
784#[stable(feature = "simd_x86", since = "1.27.0")]
785#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
786pub const fn _mm256_cvtepi32_epi64(a: __m128i) -> __m256i {
787 unsafe { transmute::<i64x4, _>(simd_cast(a.as_i32x4())) }
788}
789
790#[inline]
794#[target_feature(enable = "avx2")]
795#[cfg_attr(test, assert_instr(vpmovsxbw))]
796#[stable(feature = "simd_x86", since = "1.27.0")]
797#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
798pub const fn _mm256_cvtepi8_epi16(a: __m128i) -> __m256i {
799 unsafe { transmute::<i16x16, _>(simd_cast(a.as_i8x16())) }
800}
801
802#[inline]
806#[target_feature(enable = "avx2")]
807#[cfg_attr(test, assert_instr(vpmovsxbd))]
808#[stable(feature = "simd_x86", since = "1.27.0")]
809#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
810pub const fn _mm256_cvtepi8_epi32(a: __m128i) -> __m256i {
811 unsafe {
812 let a = a.as_i8x16();
813 let v64: i8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]);
814 transmute::<i32x8, _>(simd_cast(v64))
815 }
816}
817
818#[inline]
822#[target_feature(enable = "avx2")]
823#[cfg_attr(test, assert_instr(vpmovsxbq))]
824#[stable(feature = "simd_x86", since = "1.27.0")]
825#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
826pub const fn _mm256_cvtepi8_epi64(a: __m128i) -> __m256i {
827 unsafe {
828 let a = a.as_i8x16();
829 let v32: i8x4 = simd_shuffle!(a, a, [0, 1, 2, 3]);
830 transmute::<i64x4, _>(simd_cast(v32))
831 }
832}
833
834#[inline]
839#[target_feature(enable = "avx2")]
840#[cfg_attr(test, assert_instr(vpmovzxwd))]
841#[stable(feature = "simd_x86", since = "1.27.0")]
842#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
843pub const fn _mm256_cvtepu16_epi32(a: __m128i) -> __m256i {
844 unsafe { transmute::<i32x8, _>(simd_cast(a.as_u16x8())) }
845}
846
847#[inline]
852#[target_feature(enable = "avx2")]
853#[cfg_attr(test, assert_instr(vpmovzxwq))]
854#[stable(feature = "simd_x86", since = "1.27.0")]
855#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
856pub const fn _mm256_cvtepu16_epi64(a: __m128i) -> __m256i {
857 unsafe {
858 let a = a.as_u16x8();
859 let v64: u16x4 = simd_shuffle!(a, a, [0, 1, 2, 3]);
860 transmute::<i64x4, _>(simd_cast(v64))
861 }
862}
863
864#[inline]
868#[target_feature(enable = "avx2")]
869#[cfg_attr(test, assert_instr(vpmovzxdq))]
870#[stable(feature = "simd_x86", since = "1.27.0")]
871#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
872pub const fn _mm256_cvtepu32_epi64(a: __m128i) -> __m256i {
873 unsafe { transmute::<i64x4, _>(simd_cast(a.as_u32x4())) }
874}
875
876#[inline]
880#[target_feature(enable = "avx2")]
881#[cfg_attr(test, assert_instr(vpmovzxbw))]
882#[stable(feature = "simd_x86", since = "1.27.0")]
883#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
884pub const fn _mm256_cvtepu8_epi16(a: __m128i) -> __m256i {
885 unsafe { transmute::<i16x16, _>(simd_cast(a.as_u8x16())) }
886}
887
888#[inline]
893#[target_feature(enable = "avx2")]
894#[cfg_attr(test, assert_instr(vpmovzxbd))]
895#[stable(feature = "simd_x86", since = "1.27.0")]
896#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
897pub const fn _mm256_cvtepu8_epi32(a: __m128i) -> __m256i {
898 unsafe {
899 let a = a.as_u8x16();
900 let v64: u8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]);
901 transmute::<i32x8, _>(simd_cast(v64))
902 }
903}
904
905#[inline]
910#[target_feature(enable = "avx2")]
911#[cfg_attr(test, assert_instr(vpmovzxbq))]
912#[stable(feature = "simd_x86", since = "1.27.0")]
913#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
914pub const fn _mm256_cvtepu8_epi64(a: __m128i) -> __m256i {
915 unsafe {
916 let a = a.as_u8x16();
917 let v32: u8x4 = simd_shuffle!(a, a, [0, 1, 2, 3]);
918 transmute::<i64x4, _>(simd_cast(v32))
919 }
920}
921
922#[inline]
926#[target_feature(enable = "avx2")]
927#[cfg_attr(test, assert_instr(vextractf128, IMM1 = 1))]
928#[rustc_legacy_const_generics(1)]
929#[stable(feature = "simd_x86", since = "1.27.0")]
930#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
931pub const fn _mm256_extracti128_si256<const IMM1: i32>(a: __m256i) -> __m128i {
932 static_assert_uimm_bits!(IMM1, 1);
933 unsafe {
934 let a = a.as_i64x4();
935 let b = i64x4::ZERO;
936 let dst: i64x2 = simd_shuffle!(a, b, [[0, 1], [2, 3]][IMM1 as usize]);
937 transmute(dst)
938 }
939}
940
941#[inline]
945#[target_feature(enable = "avx2")]
946#[cfg_attr(test, assert_instr(vphaddw))]
947#[stable(feature = "simd_x86", since = "1.27.0")]
948#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
949pub const fn _mm256_hadd_epi16(a: __m256i, b: __m256i) -> __m256i {
950 let a = a.as_i16x16();
951 let b = b.as_i16x16();
952 unsafe {
953 let even: i16x16 = simd_shuffle!(
954 a,
955 b,
956 [0, 2, 4, 6, 16, 18, 20, 22, 8, 10, 12, 14, 24, 26, 28, 30]
957 );
958 let odd: i16x16 = simd_shuffle!(
959 a,
960 b,
961 [1, 3, 5, 7, 17, 19, 21, 23, 9, 11, 13, 15, 25, 27, 29, 31]
962 );
963 simd_add(even, odd).as_m256i()
964 }
965}
966
967#[inline]
971#[target_feature(enable = "avx2")]
972#[cfg_attr(test, assert_instr(vphaddd))]
973#[stable(feature = "simd_x86", since = "1.27.0")]
974#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
975pub const fn _mm256_hadd_epi32(a: __m256i, b: __m256i) -> __m256i {
976 let a = a.as_i32x8();
977 let b = b.as_i32x8();
978 unsafe {
979 let even: i32x8 = simd_shuffle!(a, b, [0, 2, 8, 10, 4, 6, 12, 14]);
980 let odd: i32x8 = simd_shuffle!(a, b, [1, 3, 9, 11, 5, 7, 13, 15]);
981 simd_add(even, odd).as_m256i()
982 }
983}
984
985#[inline]
990#[target_feature(enable = "avx2")]
991#[cfg_attr(test, assert_instr(vphaddsw))]
992#[stable(feature = "simd_x86", since = "1.27.0")]
993pub fn _mm256_hadds_epi16(a: __m256i, b: __m256i) -> __m256i {
994 let a = a.as_i16x16();
995 let b = b.as_i16x16();
996 unsafe {
997 let even: i16x16 = simd_shuffle!(
998 a,
999 b,
1000 [0, 2, 4, 6, 16, 18, 20, 22, 8, 10, 12, 14, 24, 26, 28, 30]
1001 );
1002 let odd: i16x16 = simd_shuffle!(
1003 a,
1004 b,
1005 [1, 3, 5, 7, 17, 19, 21, 23, 9, 11, 13, 15, 25, 27, 29, 31]
1006 );
1007 simd_saturating_add(even, odd).as_m256i()
1008 }
1009}
1010
1011#[inline]
1015#[target_feature(enable = "avx2")]
1016#[cfg_attr(test, assert_instr(vphsubw))]
1017#[stable(feature = "simd_x86", since = "1.27.0")]
1018#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1019pub const fn _mm256_hsub_epi16(a: __m256i, b: __m256i) -> __m256i {
1020 let a = a.as_i16x16();
1021 let b = b.as_i16x16();
1022 unsafe {
1023 let even: i16x16 = simd_shuffle!(
1024 a,
1025 b,
1026 [0, 2, 4, 6, 16, 18, 20, 22, 8, 10, 12, 14, 24, 26, 28, 30]
1027 );
1028 let odd: i16x16 = simd_shuffle!(
1029 a,
1030 b,
1031 [1, 3, 5, 7, 17, 19, 21, 23, 9, 11, 13, 15, 25, 27, 29, 31]
1032 );
1033 simd_sub(even, odd).as_m256i()
1034 }
1035}
1036
1037#[inline]
1041#[target_feature(enable = "avx2")]
1042#[cfg_attr(test, assert_instr(vphsubd))]
1043#[stable(feature = "simd_x86", since = "1.27.0")]
1044#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1045pub const fn _mm256_hsub_epi32(a: __m256i, b: __m256i) -> __m256i {
1046 let a = a.as_i32x8();
1047 let b = b.as_i32x8();
1048 unsafe {
1049 let even: i32x8 = simd_shuffle!(a, b, [0, 2, 8, 10, 4, 6, 12, 14]);
1050 let odd: i32x8 = simd_shuffle!(a, b, [1, 3, 9, 11, 5, 7, 13, 15]);
1051 simd_sub(even, odd).as_m256i()
1052 }
1053}
1054
1055#[inline]
1060#[target_feature(enable = "avx2")]
1061#[cfg_attr(test, assert_instr(vphsubsw))]
1062#[stable(feature = "simd_x86", since = "1.27.0")]
1063pub fn _mm256_hsubs_epi16(a: __m256i, b: __m256i) -> __m256i {
1064 let a = a.as_i16x16();
1065 let b = b.as_i16x16();
1066 unsafe {
1067 let even: i16x16 = simd_shuffle!(
1068 a,
1069 b,
1070 [0, 2, 4, 6, 16, 18, 20, 22, 8, 10, 12, 14, 24, 26, 28, 30]
1071 );
1072 let odd: i16x16 = simd_shuffle!(
1073 a,
1074 b,
1075 [1, 3, 5, 7, 17, 19, 21, 23, 9, 11, 13, 15, 25, 27, 29, 31]
1076 );
1077 simd_saturating_sub(even, odd).as_m256i()
1078 }
1079}
1080
1081#[inline]
1087#[target_feature(enable = "avx2")]
1088#[cfg_attr(test, assert_instr(vpgatherdd, SCALE = 1))]
1089#[rustc_legacy_const_generics(2)]
1090#[stable(feature = "simd_x86", since = "1.27.0")]
1091pub unsafe fn _mm_i32gather_epi32<const SCALE: i32>(
1092 slice: *const i32,
1093 offsets: __m128i,
1094) -> __m128i {
1095 static_assert_imm8_scale!(SCALE);
1096 let zero = i32x4::ZERO;
1097 let neg_one = _mm_set1_epi32(-1).as_i32x4();
1098 let offsets = offsets.as_i32x4();
1099 let slice = slice as *const i8;
1100 let r = pgatherdd(zero, slice, offsets, neg_one, SCALE as i8);
1101 transmute(r)
1102}
1103
1104#[inline]
1111#[target_feature(enable = "avx2")]
1112#[cfg_attr(test, assert_instr(vpgatherdd, SCALE = 1))]
1113#[rustc_legacy_const_generics(4)]
1114#[stable(feature = "simd_x86", since = "1.27.0")]
1115pub unsafe fn _mm_mask_i32gather_epi32<const SCALE: i32>(
1116 src: __m128i,
1117 slice: *const i32,
1118 offsets: __m128i,
1119 mask: __m128i,
1120) -> __m128i {
1121 static_assert_imm8_scale!(SCALE);
1122 let src = src.as_i32x4();
1123 let mask = mask.as_i32x4();
1124 let offsets = offsets.as_i32x4();
1125 let slice = slice as *const i8;
1126 let r = pgatherdd(src, slice, offsets, mask, SCALE as i8);
1127 transmute(r)
1128}
1129
1130#[inline]
1136#[target_feature(enable = "avx2")]
1137#[cfg_attr(test, assert_instr(vpgatherdd, SCALE = 1))]
1138#[rustc_legacy_const_generics(2)]
1139#[stable(feature = "simd_x86", since = "1.27.0")]
1140pub unsafe fn _mm256_i32gather_epi32<const SCALE: i32>(
1141 slice: *const i32,
1142 offsets: __m256i,
1143) -> __m256i {
1144 static_assert_imm8_scale!(SCALE);
1145 let zero = i32x8::ZERO;
1146 let neg_one = _mm256_set1_epi32(-1).as_i32x8();
1147 let offsets = offsets.as_i32x8();
1148 let slice = slice as *const i8;
1149 let r = vpgatherdd(zero, slice, offsets, neg_one, SCALE as i8);
1150 transmute(r)
1151}
1152
1153#[inline]
1160#[target_feature(enable = "avx2")]
1161#[cfg_attr(test, assert_instr(vpgatherdd, SCALE = 1))]
1162#[rustc_legacy_const_generics(4)]
1163#[stable(feature = "simd_x86", since = "1.27.0")]
1164pub unsafe fn _mm256_mask_i32gather_epi32<const SCALE: i32>(
1165 src: __m256i,
1166 slice: *const i32,
1167 offsets: __m256i,
1168 mask: __m256i,
1169) -> __m256i {
1170 static_assert_imm8_scale!(SCALE);
1171 let src = src.as_i32x8();
1172 let mask = mask.as_i32x8();
1173 let offsets = offsets.as_i32x8();
1174 let slice = slice as *const i8;
1175 let r = vpgatherdd(src, slice, offsets, mask, SCALE as i8);
1176 transmute(r)
1177}
1178
1179#[inline]
1185#[target_feature(enable = "avx2")]
1186#[cfg_attr(test, assert_instr(vgatherdps, SCALE = 1))]
1187#[rustc_legacy_const_generics(2)]
1188#[stable(feature = "simd_x86", since = "1.27.0")]
1189pub unsafe fn _mm_i32gather_ps<const SCALE: i32>(slice: *const f32, offsets: __m128i) -> __m128 {
1190 static_assert_imm8_scale!(SCALE);
1191 let zero = _mm_setzero_ps();
1192 let neg_one = _mm_set1_ps(-1.0);
1193 let offsets = offsets.as_i32x4();
1194 let slice = slice as *const i8;
1195 pgatherdps(zero, slice, offsets, neg_one, SCALE as i8)
1196}
1197
1198#[inline]
1205#[target_feature(enable = "avx2")]
1206#[cfg_attr(test, assert_instr(vgatherdps, SCALE = 1))]
1207#[rustc_legacy_const_generics(4)]
1208#[stable(feature = "simd_x86", since = "1.27.0")]
1209pub unsafe fn _mm_mask_i32gather_ps<const SCALE: i32>(
1210 src: __m128,
1211 slice: *const f32,
1212 offsets: __m128i,
1213 mask: __m128,
1214) -> __m128 {
1215 static_assert_imm8_scale!(SCALE);
1216 let offsets = offsets.as_i32x4();
1217 let slice = slice as *const i8;
1218 pgatherdps(src, slice, offsets, mask, SCALE as i8)
1219}
1220
1221#[inline]
1227#[target_feature(enable = "avx2")]
1228#[cfg_attr(test, assert_instr(vgatherdps, SCALE = 1))]
1229#[rustc_legacy_const_generics(2)]
1230#[stable(feature = "simd_x86", since = "1.27.0")]
1231pub unsafe fn _mm256_i32gather_ps<const SCALE: i32>(slice: *const f32, offsets: __m256i) -> __m256 {
1232 static_assert_imm8_scale!(SCALE);
1233 let zero = _mm256_setzero_ps();
1234 let neg_one = _mm256_set1_ps(-1.0);
1235 let offsets = offsets.as_i32x8();
1236 let slice = slice as *const i8;
1237 vpgatherdps(zero, slice, offsets, neg_one, SCALE as i8)
1238}
1239
1240#[inline]
1247#[target_feature(enable = "avx2")]
1248#[cfg_attr(test, assert_instr(vgatherdps, SCALE = 1))]
1249#[rustc_legacy_const_generics(4)]
1250#[stable(feature = "simd_x86", since = "1.27.0")]
1251pub unsafe fn _mm256_mask_i32gather_ps<const SCALE: i32>(
1252 src: __m256,
1253 slice: *const f32,
1254 offsets: __m256i,
1255 mask: __m256,
1256) -> __m256 {
1257 static_assert_imm8_scale!(SCALE);
1258 let offsets = offsets.as_i32x8();
1259 let slice = slice as *const i8;
1260 vpgatherdps(src, slice, offsets, mask, SCALE as i8)
1261}
1262
1263#[inline]
1269#[target_feature(enable = "avx2")]
1270#[cfg_attr(test, assert_instr(vpgatherdq, SCALE = 1))]
1271#[rustc_legacy_const_generics(2)]
1272#[stable(feature = "simd_x86", since = "1.27.0")]
1273pub unsafe fn _mm_i32gather_epi64<const SCALE: i32>(
1274 slice: *const i64,
1275 offsets: __m128i,
1276) -> __m128i {
1277 static_assert_imm8_scale!(SCALE);
1278 let zero = i64x2::ZERO;
1279 let neg_one = _mm_set1_epi64x(-1).as_i64x2();
1280 let offsets = offsets.as_i32x4();
1281 let slice = slice as *const i8;
1282 let r = pgatherdq(zero, slice, offsets, neg_one, SCALE as i8);
1283 transmute(r)
1284}
1285
1286#[inline]
1293#[target_feature(enable = "avx2")]
1294#[cfg_attr(test, assert_instr(vpgatherdq, SCALE = 1))]
1295#[rustc_legacy_const_generics(4)]
1296#[stable(feature = "simd_x86", since = "1.27.0")]
1297pub unsafe fn _mm_mask_i32gather_epi64<const SCALE: i32>(
1298 src: __m128i,
1299 slice: *const i64,
1300 offsets: __m128i,
1301 mask: __m128i,
1302) -> __m128i {
1303 static_assert_imm8_scale!(SCALE);
1304 let src = src.as_i64x2();
1305 let mask = mask.as_i64x2();
1306 let offsets = offsets.as_i32x4();
1307 let slice = slice as *const i8;
1308 let r = pgatherdq(src, slice, offsets, mask, SCALE as i8);
1309 transmute(r)
1310}
1311
1312#[inline]
1318#[target_feature(enable = "avx2")]
1319#[cfg_attr(test, assert_instr(vpgatherdq, SCALE = 1))]
1320#[rustc_legacy_const_generics(2)]
1321#[stable(feature = "simd_x86", since = "1.27.0")]
1322pub unsafe fn _mm256_i32gather_epi64<const SCALE: i32>(
1323 slice: *const i64,
1324 offsets: __m128i,
1325) -> __m256i {
1326 static_assert_imm8_scale!(SCALE);
1327 let zero = i64x4::ZERO;
1328 let neg_one = _mm256_set1_epi64x(-1).as_i64x4();
1329 let offsets = offsets.as_i32x4();
1330 let slice = slice as *const i8;
1331 let r = vpgatherdq(zero, slice, offsets, neg_one, SCALE as i8);
1332 transmute(r)
1333}
1334
1335#[inline]
1342#[target_feature(enable = "avx2")]
1343#[cfg_attr(test, assert_instr(vpgatherdq, SCALE = 1))]
1344#[rustc_legacy_const_generics(4)]
1345#[stable(feature = "simd_x86", since = "1.27.0")]
1346pub unsafe fn _mm256_mask_i32gather_epi64<const SCALE: i32>(
1347 src: __m256i,
1348 slice: *const i64,
1349 offsets: __m128i,
1350 mask: __m256i,
1351) -> __m256i {
1352 static_assert_imm8_scale!(SCALE);
1353 let src = src.as_i64x4();
1354 let mask = mask.as_i64x4();
1355 let offsets = offsets.as_i32x4();
1356 let slice = slice as *const i8;
1357 let r = vpgatherdq(src, slice, offsets, mask, SCALE as i8);
1358 transmute(r)
1359}
1360
1361#[inline]
1367#[target_feature(enable = "avx2")]
1368#[cfg_attr(test, assert_instr(vgatherdpd, SCALE = 1))]
1369#[rustc_legacy_const_generics(2)]
1370#[stable(feature = "simd_x86", since = "1.27.0")]
1371pub unsafe fn _mm_i32gather_pd<const SCALE: i32>(slice: *const f64, offsets: __m128i) -> __m128d {
1372 static_assert_imm8_scale!(SCALE);
1373 let zero = _mm_setzero_pd();
1374 let neg_one = _mm_set1_pd(-1.0);
1375 let offsets = offsets.as_i32x4();
1376 let slice = slice as *const i8;
1377 pgatherdpd(zero, slice, offsets, neg_one, SCALE as i8)
1378}
1379
1380#[inline]
1387#[target_feature(enable = "avx2")]
1388#[cfg_attr(test, assert_instr(vgatherdpd, SCALE = 1))]
1389#[rustc_legacy_const_generics(4)]
1390#[stable(feature = "simd_x86", since = "1.27.0")]
1391pub unsafe fn _mm_mask_i32gather_pd<const SCALE: i32>(
1392 src: __m128d,
1393 slice: *const f64,
1394 offsets: __m128i,
1395 mask: __m128d,
1396) -> __m128d {
1397 static_assert_imm8_scale!(SCALE);
1398 let offsets = offsets.as_i32x4();
1399 let slice = slice as *const i8;
1400 pgatherdpd(src, slice, offsets, mask, SCALE as i8)
1401}
1402
1403#[inline]
1409#[target_feature(enable = "avx2")]
1410#[cfg_attr(test, assert_instr(vgatherdpd, SCALE = 1))]
1411#[rustc_legacy_const_generics(2)]
1412#[stable(feature = "simd_x86", since = "1.27.0")]
1413pub unsafe fn _mm256_i32gather_pd<const SCALE: i32>(
1414 slice: *const f64,
1415 offsets: __m128i,
1416) -> __m256d {
1417 static_assert_imm8_scale!(SCALE);
1418 let zero = _mm256_setzero_pd();
1419 let neg_one = _mm256_set1_pd(-1.0);
1420 let offsets = offsets.as_i32x4();
1421 let slice = slice as *const i8;
1422 vpgatherdpd(zero, slice, offsets, neg_one, SCALE as i8)
1423}
1424
1425#[inline]
1432#[target_feature(enable = "avx2")]
1433#[cfg_attr(test, assert_instr(vgatherdpd, SCALE = 1))]
1434#[rustc_legacy_const_generics(4)]
1435#[stable(feature = "simd_x86", since = "1.27.0")]
1436pub unsafe fn _mm256_mask_i32gather_pd<const SCALE: i32>(
1437 src: __m256d,
1438 slice: *const f64,
1439 offsets: __m128i,
1440 mask: __m256d,
1441) -> __m256d {
1442 static_assert_imm8_scale!(SCALE);
1443 let offsets = offsets.as_i32x4();
1444 let slice = slice as *const i8;
1445 vpgatherdpd(src, slice, offsets, mask, SCALE as i8)
1446}
1447
1448#[inline]
1454#[target_feature(enable = "avx2")]
1455#[cfg_attr(test, assert_instr(vpgatherqd, SCALE = 1))]
1456#[rustc_legacy_const_generics(2)]
1457#[stable(feature = "simd_x86", since = "1.27.0")]
1458pub unsafe fn _mm_i64gather_epi32<const SCALE: i32>(
1459 slice: *const i32,
1460 offsets: __m128i,
1461) -> __m128i {
1462 static_assert_imm8_scale!(SCALE);
1463 let zero = i32x4::ZERO;
1464 let neg_one = _mm_set1_epi64x(-1).as_i32x4();
1465 let offsets = offsets.as_i64x2();
1466 let slice = slice as *const i8;
1467 let r = pgatherqd(zero, slice, offsets, neg_one, SCALE as i8);
1468 transmute(r)
1469}
1470
1471#[inline]
1478#[target_feature(enable = "avx2")]
1479#[cfg_attr(test, assert_instr(vpgatherqd, SCALE = 1))]
1480#[rustc_legacy_const_generics(4)]
1481#[stable(feature = "simd_x86", since = "1.27.0")]
1482pub unsafe fn _mm_mask_i64gather_epi32<const SCALE: i32>(
1483 src: __m128i,
1484 slice: *const i32,
1485 offsets: __m128i,
1486 mask: __m128i,
1487) -> __m128i {
1488 static_assert_imm8_scale!(SCALE);
1489 let src = src.as_i32x4();
1490 let mask = mask.as_i32x4();
1491 let offsets = offsets.as_i64x2();
1492 let slice = slice as *const i8;
1493 let r = pgatherqd(src, slice, offsets, mask, SCALE as i8);
1494 transmute(r)
1495}
1496
1497#[inline]
1503#[target_feature(enable = "avx2")]
1504#[cfg_attr(test, assert_instr(vpgatherqd, SCALE = 1))]
1505#[rustc_legacy_const_generics(2)]
1506#[stable(feature = "simd_x86", since = "1.27.0")]
1507pub unsafe fn _mm256_i64gather_epi32<const SCALE: i32>(
1508 slice: *const i32,
1509 offsets: __m256i,
1510) -> __m128i {
1511 static_assert_imm8_scale!(SCALE);
1512 let zero = i32x4::ZERO;
1513 let neg_one = _mm_set1_epi64x(-1).as_i32x4();
1514 let offsets = offsets.as_i64x4();
1515 let slice = slice as *const i8;
1516 let r = vpgatherqd(zero, slice, offsets, neg_one, SCALE as i8);
1517 transmute(r)
1518}
1519
1520#[inline]
1527#[target_feature(enable = "avx2")]
1528#[cfg_attr(test, assert_instr(vpgatherqd, SCALE = 1))]
1529#[rustc_legacy_const_generics(4)]
1530#[stable(feature = "simd_x86", since = "1.27.0")]
1531pub unsafe fn _mm256_mask_i64gather_epi32<const SCALE: i32>(
1532 src: __m128i,
1533 slice: *const i32,
1534 offsets: __m256i,
1535 mask: __m128i,
1536) -> __m128i {
1537 static_assert_imm8_scale!(SCALE);
1538 let src = src.as_i32x4();
1539 let mask = mask.as_i32x4();
1540 let offsets = offsets.as_i64x4();
1541 let slice = slice as *const i8;
1542 let r = vpgatherqd(src, slice, offsets, mask, SCALE as i8);
1543 transmute(r)
1544}
1545
1546#[inline]
1552#[target_feature(enable = "avx2")]
1553#[cfg_attr(test, assert_instr(vgatherqps, SCALE = 1))]
1554#[rustc_legacy_const_generics(2)]
1555#[stable(feature = "simd_x86", since = "1.27.0")]
1556pub unsafe fn _mm_i64gather_ps<const SCALE: i32>(slice: *const f32, offsets: __m128i) -> __m128 {
1557 static_assert_imm8_scale!(SCALE);
1558 let zero = _mm_setzero_ps();
1559 let neg_one = _mm_set1_ps(-1.0);
1560 let offsets = offsets.as_i64x2();
1561 let slice = slice as *const i8;
1562 pgatherqps(zero, slice, offsets, neg_one, SCALE as i8)
1563}
1564
1565#[inline]
1572#[target_feature(enable = "avx2")]
1573#[cfg_attr(test, assert_instr(vgatherqps, SCALE = 1))]
1574#[rustc_legacy_const_generics(4)]
1575#[stable(feature = "simd_x86", since = "1.27.0")]
1576pub unsafe fn _mm_mask_i64gather_ps<const SCALE: i32>(
1577 src: __m128,
1578 slice: *const f32,
1579 offsets: __m128i,
1580 mask: __m128,
1581) -> __m128 {
1582 static_assert_imm8_scale!(SCALE);
1583 let offsets = offsets.as_i64x2();
1584 let slice = slice as *const i8;
1585 pgatherqps(src, slice, offsets, mask, SCALE as i8)
1586}
1587
1588#[inline]
1594#[target_feature(enable = "avx2")]
1595#[cfg_attr(test, assert_instr(vgatherqps, SCALE = 1))]
1596#[rustc_legacy_const_generics(2)]
1597#[stable(feature = "simd_x86", since = "1.27.0")]
1598pub unsafe fn _mm256_i64gather_ps<const SCALE: i32>(slice: *const f32, offsets: __m256i) -> __m128 {
1599 static_assert_imm8_scale!(SCALE);
1600 let zero = _mm_setzero_ps();
1601 let neg_one = _mm_set1_ps(-1.0);
1602 let offsets = offsets.as_i64x4();
1603 let slice = slice as *const i8;
1604 vpgatherqps(zero, slice, offsets, neg_one, SCALE as i8)
1605}
1606
1607#[inline]
1614#[target_feature(enable = "avx2")]
1615#[cfg_attr(test, assert_instr(vgatherqps, SCALE = 1))]
1616#[rustc_legacy_const_generics(4)]
1617#[stable(feature = "simd_x86", since = "1.27.0")]
1618pub unsafe fn _mm256_mask_i64gather_ps<const SCALE: i32>(
1619 src: __m128,
1620 slice: *const f32,
1621 offsets: __m256i,
1622 mask: __m128,
1623) -> __m128 {
1624 static_assert_imm8_scale!(SCALE);
1625 let offsets = offsets.as_i64x4();
1626 let slice = slice as *const i8;
1627 vpgatherqps(src, slice, offsets, mask, SCALE as i8)
1628}
1629
1630#[inline]
1636#[target_feature(enable = "avx2")]
1637#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1638#[rustc_legacy_const_generics(2)]
1639#[stable(feature = "simd_x86", since = "1.27.0")]
1640pub unsafe fn _mm_i64gather_epi64<const SCALE: i32>(
1641 slice: *const i64,
1642 offsets: __m128i,
1643) -> __m128i {
1644 static_assert_imm8_scale!(SCALE);
1645 let zero = i64x2::ZERO;
1646 let neg_one = _mm_set1_epi64x(-1).as_i64x2();
1647 let slice = slice as *const i8;
1648 let offsets = offsets.as_i64x2();
1649 let r = pgatherqq(zero, slice, offsets, neg_one, SCALE as i8);
1650 transmute(r)
1651}
1652
1653#[inline]
1660#[target_feature(enable = "avx2")]
1661#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1662#[rustc_legacy_const_generics(4)]
1663#[stable(feature = "simd_x86", since = "1.27.0")]
1664pub unsafe fn _mm_mask_i64gather_epi64<const SCALE: i32>(
1665 src: __m128i,
1666 slice: *const i64,
1667 offsets: __m128i,
1668 mask: __m128i,
1669) -> __m128i {
1670 static_assert_imm8_scale!(SCALE);
1671 let src = src.as_i64x2();
1672 let mask = mask.as_i64x2();
1673 let offsets = offsets.as_i64x2();
1674 let slice = slice as *const i8;
1675 let r = pgatherqq(src, slice, offsets, mask, SCALE as i8);
1676 transmute(r)
1677}
1678
1679#[inline]
1685#[target_feature(enable = "avx2")]
1686#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1687#[rustc_legacy_const_generics(2)]
1688#[stable(feature = "simd_x86", since = "1.27.0")]
1689pub unsafe fn _mm256_i64gather_epi64<const SCALE: i32>(
1690 slice: *const i64,
1691 offsets: __m256i,
1692) -> __m256i {
1693 static_assert_imm8_scale!(SCALE);
1694 let zero = i64x4::ZERO;
1695 let neg_one = _mm256_set1_epi64x(-1).as_i64x4();
1696 let slice = slice as *const i8;
1697 let offsets = offsets.as_i64x4();
1698 let r = vpgatherqq(zero, slice, offsets, neg_one, SCALE as i8);
1699 transmute(r)
1700}
1701
1702#[inline]
1709#[target_feature(enable = "avx2")]
1710#[cfg_attr(test, assert_instr(vpgatherqq, SCALE = 1))]
1711#[rustc_legacy_const_generics(4)]
1712#[stable(feature = "simd_x86", since = "1.27.0")]
1713pub unsafe fn _mm256_mask_i64gather_epi64<const SCALE: i32>(
1714 src: __m256i,
1715 slice: *const i64,
1716 offsets: __m256i,
1717 mask: __m256i,
1718) -> __m256i {
1719 static_assert_imm8_scale!(SCALE);
1720 let src = src.as_i64x4();
1721 let mask = mask.as_i64x4();
1722 let offsets = offsets.as_i64x4();
1723 let slice = slice as *const i8;
1724 let r = vpgatherqq(src, slice, offsets, mask, SCALE as i8);
1725 transmute(r)
1726}
1727
1728#[inline]
1734#[target_feature(enable = "avx2")]
1735#[cfg_attr(test, assert_instr(vgatherqpd, SCALE = 1))]
1736#[rustc_legacy_const_generics(2)]
1737#[stable(feature = "simd_x86", since = "1.27.0")]
1738pub unsafe fn _mm_i64gather_pd<const SCALE: i32>(slice: *const f64, offsets: __m128i) -> __m128d {
1739 static_assert_imm8_scale!(SCALE);
1740 let zero = _mm_setzero_pd();
1741 let neg_one = _mm_set1_pd(-1.0);
1742 let slice = slice as *const i8;
1743 let offsets = offsets.as_i64x2();
1744 pgatherqpd(zero, slice, offsets, neg_one, SCALE as i8)
1745}
1746
1747#[inline]
1754#[target_feature(enable = "avx2")]
1755#[cfg_attr(test, assert_instr(vgatherqpd, SCALE = 1))]
1756#[rustc_legacy_const_generics(4)]
1757#[stable(feature = "simd_x86", since = "1.27.0")]
1758pub unsafe fn _mm_mask_i64gather_pd<const SCALE: i32>(
1759 src: __m128d,
1760 slice: *const f64,
1761 offsets: __m128i,
1762 mask: __m128d,
1763) -> __m128d {
1764 static_assert_imm8_scale!(SCALE);
1765 let slice = slice as *const i8;
1766 let offsets = offsets.as_i64x2();
1767 pgatherqpd(src, slice, offsets, mask, SCALE as i8)
1768}
1769
1770#[inline]
1776#[target_feature(enable = "avx2")]
1777#[cfg_attr(test, assert_instr(vgatherqpd, SCALE = 1))]
1778#[rustc_legacy_const_generics(2)]
1779#[stable(feature = "simd_x86", since = "1.27.0")]
1780pub unsafe fn _mm256_i64gather_pd<const SCALE: i32>(
1781 slice: *const f64,
1782 offsets: __m256i,
1783) -> __m256d {
1784 static_assert_imm8_scale!(SCALE);
1785 let zero = _mm256_setzero_pd();
1786 let neg_one = _mm256_set1_pd(-1.0);
1787 let slice = slice as *const i8;
1788 let offsets = offsets.as_i64x4();
1789 vpgatherqpd(zero, slice, offsets, neg_one, SCALE as i8)
1790}
1791
1792#[inline]
1799#[target_feature(enable = "avx2")]
1800#[cfg_attr(test, assert_instr(vgatherqpd, SCALE = 1))]
1801#[rustc_legacy_const_generics(4)]
1802#[stable(feature = "simd_x86", since = "1.27.0")]
1803pub unsafe fn _mm256_mask_i64gather_pd<const SCALE: i32>(
1804 src: __m256d,
1805 slice: *const f64,
1806 offsets: __m256i,
1807 mask: __m256d,
1808) -> __m256d {
1809 static_assert_imm8_scale!(SCALE);
1810 let slice = slice as *const i8;
1811 let offsets = offsets.as_i64x4();
1812 vpgatherqpd(src, slice, offsets, mask, SCALE as i8)
1813}
1814
1815#[inline]
1820#[target_feature(enable = "avx2")]
1821#[cfg_attr(test, assert_instr(vinsertf128, IMM1 = 1))]
1822#[rustc_legacy_const_generics(2)]
1823#[stable(feature = "simd_x86", since = "1.27.0")]
1824#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1825pub const fn _mm256_inserti128_si256<const IMM1: i32>(a: __m256i, b: __m128i) -> __m256i {
1826 static_assert_uimm_bits!(IMM1, 1);
1827 unsafe {
1828 let a = a.as_i64x4();
1829 let b = _mm256_castsi128_si256(b).as_i64x4();
1830 let dst: i64x4 = simd_shuffle!(a, b, [[4, 5, 2, 3], [0, 1, 4, 5]][IMM1 as usize]);
1831 transmute(dst)
1832 }
1833}
1834
1835#[inline]
1841#[target_feature(enable = "avx2")]
1842#[cfg_attr(test, assert_instr(vpmaddwd))]
1843#[stable(feature = "simd_x86", since = "1.27.0")]
1844pub fn _mm256_madd_epi16(a: __m256i, b: __m256i) -> __m256i {
1845 unsafe { transmute(pmaddwd(a.as_i16x16(), b.as_i16x16())) }
1858}
1859
1860#[inline]
1867#[target_feature(enable = "avx2")]
1868#[cfg_attr(test, assert_instr(vpmaddubsw))]
1869#[stable(feature = "simd_x86", since = "1.27.0")]
1870pub fn _mm256_maddubs_epi16(a: __m256i, b: __m256i) -> __m256i {
1871 unsafe { transmute(pmaddubsw(a.as_u8x32(), b.as_i8x32())) }
1872}
1873
1874#[inline]
1880#[target_feature(enable = "avx2")]
1881#[cfg_attr(test, assert_instr(vpmaskmovd))]
1882#[stable(feature = "simd_x86", since = "1.27.0")]
1883#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1884pub const unsafe fn _mm_maskload_epi32(mem_addr: *const i32, mask: __m128i) -> __m128i {
1885 let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31));
1886 simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i32x4::ZERO).as_m128i()
1887}
1888
1889#[inline]
1895#[target_feature(enable = "avx2")]
1896#[cfg_attr(test, assert_instr(vpmaskmovd))]
1897#[stable(feature = "simd_x86", since = "1.27.0")]
1898#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1899pub const unsafe fn _mm256_maskload_epi32(mem_addr: *const i32, mask: __m256i) -> __m256i {
1900 let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31));
1901 simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i32x8::ZERO).as_m256i()
1902}
1903
1904#[inline]
1910#[target_feature(enable = "avx2")]
1911#[cfg_attr(test, assert_instr(vpmaskmovq))]
1912#[stable(feature = "simd_x86", since = "1.27.0")]
1913#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1914pub const unsafe fn _mm_maskload_epi64(mem_addr: *const i64, mask: __m128i) -> __m128i {
1915 let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63));
1916 simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i64x2::ZERO).as_m128i()
1917}
1918
1919#[inline]
1925#[target_feature(enable = "avx2")]
1926#[cfg_attr(test, assert_instr(vpmaskmovq))]
1927#[stable(feature = "simd_x86", since = "1.27.0")]
1928#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1929pub const unsafe fn _mm256_maskload_epi64(mem_addr: *const i64, mask: __m256i) -> __m256i {
1930 let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63));
1931 simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i64x4::ZERO).as_m256i()
1932}
1933
1934#[inline]
1940#[target_feature(enable = "avx2")]
1941#[cfg_attr(test, assert_instr(vpmaskmovd))]
1942#[stable(feature = "simd_x86", since = "1.27.0")]
1943#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1944pub const unsafe fn _mm_maskstore_epi32(mem_addr: *mut i32, mask: __m128i, a: __m128i) {
1945 let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31));
1946 simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x4())
1947}
1948
1949#[inline]
1955#[target_feature(enable = "avx2")]
1956#[cfg_attr(test, assert_instr(vpmaskmovd))]
1957#[stable(feature = "simd_x86", since = "1.27.0")]
1958#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1959pub const unsafe fn _mm256_maskstore_epi32(mem_addr: *mut i32, mask: __m256i, a: __m256i) {
1960 let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31));
1961 simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x8())
1962}
1963
1964#[inline]
1970#[target_feature(enable = "avx2")]
1971#[cfg_attr(test, assert_instr(vpmaskmovq))]
1972#[stable(feature = "simd_x86", since = "1.27.0")]
1973#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1974pub const unsafe fn _mm_maskstore_epi64(mem_addr: *mut i64, mask: __m128i, a: __m128i) {
1975 let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63));
1976 simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x2())
1977}
1978
1979#[inline]
1985#[target_feature(enable = "avx2")]
1986#[cfg_attr(test, assert_instr(vpmaskmovq))]
1987#[stable(feature = "simd_x86", since = "1.27.0")]
1988#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1989pub const unsafe fn _mm256_maskstore_epi64(mem_addr: *mut i64, mask: __m256i, a: __m256i) {
1990 let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63));
1991 simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x4())
1992}
1993
1994#[inline]
1999#[target_feature(enable = "avx2")]
2000#[cfg_attr(test, assert_instr(vpmaxsw))]
2001#[stable(feature = "simd_x86", since = "1.27.0")]
2002#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2003pub const fn _mm256_max_epi16(a: __m256i, b: __m256i) -> __m256i {
2004 unsafe { simd_imax(a.as_i16x16(), b.as_i16x16()).as_m256i() }
2005}
2006
2007#[inline]
2012#[target_feature(enable = "avx2")]
2013#[cfg_attr(test, assert_instr(vpmaxsd))]
2014#[stable(feature = "simd_x86", since = "1.27.0")]
2015#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2016pub const fn _mm256_max_epi32(a: __m256i, b: __m256i) -> __m256i {
2017 unsafe { simd_imax(a.as_i32x8(), b.as_i32x8()).as_m256i() }
2018}
2019
2020#[inline]
2025#[target_feature(enable = "avx2")]
2026#[cfg_attr(test, assert_instr(vpmaxsb))]
2027#[stable(feature = "simd_x86", since = "1.27.0")]
2028#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2029pub const fn _mm256_max_epi8(a: __m256i, b: __m256i) -> __m256i {
2030 unsafe { simd_imax(a.as_i8x32(), b.as_i8x32()).as_m256i() }
2031}
2032
2033#[inline]
2038#[target_feature(enable = "avx2")]
2039#[cfg_attr(test, assert_instr(vpmaxuw))]
2040#[stable(feature = "simd_x86", since = "1.27.0")]
2041#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2042pub const fn _mm256_max_epu16(a: __m256i, b: __m256i) -> __m256i {
2043 unsafe { simd_imax(a.as_u16x16(), b.as_u16x16()).as_m256i() }
2044}
2045
2046#[inline]
2051#[target_feature(enable = "avx2")]
2052#[cfg_attr(test, assert_instr(vpmaxud))]
2053#[stable(feature = "simd_x86", since = "1.27.0")]
2054#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2055pub const fn _mm256_max_epu32(a: __m256i, b: __m256i) -> __m256i {
2056 unsafe { simd_imax(a.as_u32x8(), b.as_u32x8()).as_m256i() }
2057}
2058
2059#[inline]
2064#[target_feature(enable = "avx2")]
2065#[cfg_attr(test, assert_instr(vpmaxub))]
2066#[stable(feature = "simd_x86", since = "1.27.0")]
2067#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2068pub const fn _mm256_max_epu8(a: __m256i, b: __m256i) -> __m256i {
2069 unsafe { simd_imax(a.as_u8x32(), b.as_u8x32()).as_m256i() }
2070}
2071
2072#[inline]
2077#[target_feature(enable = "avx2")]
2078#[cfg_attr(test, assert_instr(vpminsw))]
2079#[stable(feature = "simd_x86", since = "1.27.0")]
2080#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2081pub const fn _mm256_min_epi16(a: __m256i, b: __m256i) -> __m256i {
2082 unsafe { simd_imin(a.as_i16x16(), b.as_i16x16()).as_m256i() }
2083}
2084
2085#[inline]
2090#[target_feature(enable = "avx2")]
2091#[cfg_attr(test, assert_instr(vpminsd))]
2092#[stable(feature = "simd_x86", since = "1.27.0")]
2093#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2094pub const fn _mm256_min_epi32(a: __m256i, b: __m256i) -> __m256i {
2095 unsafe { simd_imin(a.as_i32x8(), b.as_i32x8()).as_m256i() }
2096}
2097
2098#[inline]
2103#[target_feature(enable = "avx2")]
2104#[cfg_attr(test, assert_instr(vpminsb))]
2105#[stable(feature = "simd_x86", since = "1.27.0")]
2106#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2107pub const fn _mm256_min_epi8(a: __m256i, b: __m256i) -> __m256i {
2108 unsafe { simd_imin(a.as_i8x32(), b.as_i8x32()).as_m256i() }
2109}
2110
2111#[inline]
2116#[target_feature(enable = "avx2")]
2117#[cfg_attr(test, assert_instr(vpminuw))]
2118#[stable(feature = "simd_x86", since = "1.27.0")]
2119#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2120pub const fn _mm256_min_epu16(a: __m256i, b: __m256i) -> __m256i {
2121 unsafe { simd_imin(a.as_u16x16(), b.as_u16x16()).as_m256i() }
2122}
2123
2124#[inline]
2129#[target_feature(enable = "avx2")]
2130#[cfg_attr(test, assert_instr(vpminud))]
2131#[stable(feature = "simd_x86", since = "1.27.0")]
2132#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2133pub const fn _mm256_min_epu32(a: __m256i, b: __m256i) -> __m256i {
2134 unsafe { simd_imin(a.as_u32x8(), b.as_u32x8()).as_m256i() }
2135}
2136
2137#[inline]
2142#[target_feature(enable = "avx2")]
2143#[cfg_attr(test, assert_instr(vpminub))]
2144#[stable(feature = "simd_x86", since = "1.27.0")]
2145#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2146pub const fn _mm256_min_epu8(a: __m256i, b: __m256i) -> __m256i {
2147 unsafe { simd_imin(a.as_u8x32(), b.as_u8x32()).as_m256i() }
2148}
2149
2150#[inline]
2155#[target_feature(enable = "avx2")]
2156#[cfg_attr(test, assert_instr(vpmovmskb))]
2157#[stable(feature = "simd_x86", since = "1.27.0")]
2158#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2159pub const fn _mm256_movemask_epi8(a: __m256i) -> i32 {
2160 unsafe {
2161 let z = i8x32::ZERO;
2162 let m: i8x32 = simd_lt(a.as_i8x32(), z);
2163 simd_bitmask::<_, u32>(m) as i32
2164 }
2165}
2166
2167#[inline]
2177#[target_feature(enable = "avx2")]
2178#[cfg_attr(test, assert_instr(vmpsadbw, IMM8 = 0))]
2179#[rustc_legacy_const_generics(2)]
2180#[stable(feature = "simd_x86", since = "1.27.0")]
2181pub fn _mm256_mpsadbw_epu8<const IMM8: i32>(a: __m256i, b: __m256i) -> __m256i {
2182 static_assert_uimm_bits!(IMM8, 8);
2183 unsafe { transmute(mpsadbw(a.as_u8x32(), b.as_u8x32(), IMM8 as i8)) }
2184}
2185
2186#[inline]
2193#[target_feature(enable = "avx2")]
2194#[cfg_attr(test, assert_instr(vpmuldq))]
2195#[stable(feature = "simd_x86", since = "1.27.0")]
2196#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2197pub const fn _mm256_mul_epi32(a: __m256i, b: __m256i) -> __m256i {
2198 unsafe {
2199 let a = simd_cast::<_, i64x4>(simd_cast::<_, i32x4>(a.as_i64x4()));
2200 let b = simd_cast::<_, i64x4>(simd_cast::<_, i32x4>(b.as_i64x4()));
2201 transmute(simd_mul(a, b))
2202 }
2203}
2204
2205#[inline]
2212#[target_feature(enable = "avx2")]
2213#[cfg_attr(test, assert_instr(vpmuludq))]
2214#[stable(feature = "simd_x86", since = "1.27.0")]
2215#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2216pub const fn _mm256_mul_epu32(a: __m256i, b: __m256i) -> __m256i {
2217 unsafe {
2218 let a = a.as_u64x4();
2219 let b = b.as_u64x4();
2220 let mask = u64x4::splat(u32::MAX as u64);
2221 transmute(simd_mul(simd_and(a, mask), simd_and(b, mask)))
2222 }
2223}
2224
2225#[inline]
2231#[target_feature(enable = "avx2")]
2232#[cfg_attr(test, assert_instr(vpmulhw))]
2233#[stable(feature = "simd_x86", since = "1.27.0")]
2234#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2235pub const fn _mm256_mulhi_epi16(a: __m256i, b: __m256i) -> __m256i {
2236 unsafe {
2237 let a = simd_cast::<_, i32x16>(a.as_i16x16());
2238 let b = simd_cast::<_, i32x16>(b.as_i16x16());
2239 let r = simd_shr(simd_mul(a, b), i32x16::splat(16));
2240 transmute(simd_cast::<i32x16, i16x16>(r))
2241 }
2242}
2243
2244#[inline]
2250#[target_feature(enable = "avx2")]
2251#[cfg_attr(test, assert_instr(vpmulhuw))]
2252#[stable(feature = "simd_x86", since = "1.27.0")]
2253#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2254pub const fn _mm256_mulhi_epu16(a: __m256i, b: __m256i) -> __m256i {
2255 unsafe {
2256 let a = simd_cast::<_, u32x16>(a.as_u16x16());
2257 let b = simd_cast::<_, u32x16>(b.as_u16x16());
2258 let r = simd_shr(simd_mul(a, b), u32x16::splat(16));
2259 transmute(simd_cast::<u32x16, u16x16>(r))
2260 }
2261}
2262
2263#[inline]
2269#[target_feature(enable = "avx2")]
2270#[cfg_attr(test, assert_instr(vpmullw))]
2271#[stable(feature = "simd_x86", since = "1.27.0")]
2272#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2273pub const fn _mm256_mullo_epi16(a: __m256i, b: __m256i) -> __m256i {
2274 unsafe { transmute(simd_mul(a.as_i16x16(), b.as_i16x16())) }
2275}
2276
2277#[inline]
2283#[target_feature(enable = "avx2")]
2284#[cfg_attr(test, assert_instr(vpmulld))]
2285#[stable(feature = "simd_x86", since = "1.27.0")]
2286#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2287pub const fn _mm256_mullo_epi32(a: __m256i, b: __m256i) -> __m256i {
2288 unsafe { transmute(simd_mul(a.as_i32x8(), b.as_i32x8())) }
2289}
2290
2291#[inline]
2298#[target_feature(enable = "avx2")]
2299#[cfg_attr(test, assert_instr(vpmulhrsw))]
2300#[stable(feature = "simd_x86", since = "1.27.0")]
2301pub fn _mm256_mulhrs_epi16(a: __m256i, b: __m256i) -> __m256i {
2302 unsafe { transmute(pmulhrsw(a.as_i16x16(), b.as_i16x16())) }
2303}
2304
2305#[inline]
2310#[target_feature(enable = "avx2")]
2311#[cfg_attr(test, assert_instr(vorps))]
2312#[stable(feature = "simd_x86", since = "1.27.0")]
2313#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2314pub const fn _mm256_or_si256(a: __m256i, b: __m256i) -> __m256i {
2315 unsafe { transmute(simd_or(a.as_i32x8(), b.as_i32x8())) }
2316}
2317
2318#[inline]
2323#[target_feature(enable = "avx2")]
2324#[cfg_attr(test, assert_instr(vpacksswb))]
2325#[stable(feature = "simd_x86", since = "1.27.0")]
2326pub fn _mm256_packs_epi16(a: __m256i, b: __m256i) -> __m256i {
2327 unsafe { transmute(packsswb(a.as_i16x16(), b.as_i16x16())) }
2328}
2329
2330#[inline]
2335#[target_feature(enable = "avx2")]
2336#[cfg_attr(test, assert_instr(vpackssdw))]
2337#[stable(feature = "simd_x86", since = "1.27.0")]
2338pub fn _mm256_packs_epi32(a: __m256i, b: __m256i) -> __m256i {
2339 unsafe { transmute(packssdw(a.as_i32x8(), b.as_i32x8())) }
2340}
2341
2342#[inline]
2347#[target_feature(enable = "avx2")]
2348#[cfg_attr(test, assert_instr(vpackuswb))]
2349#[stable(feature = "simd_x86", since = "1.27.0")]
2350pub fn _mm256_packus_epi16(a: __m256i, b: __m256i) -> __m256i {
2351 unsafe { transmute(packuswb(a.as_i16x16(), b.as_i16x16())) }
2352}
2353
2354#[inline]
2359#[target_feature(enable = "avx2")]
2360#[cfg_attr(test, assert_instr(vpackusdw))]
2361#[stable(feature = "simd_x86", since = "1.27.0")]
2362pub fn _mm256_packus_epi32(a: __m256i, b: __m256i) -> __m256i {
2363 unsafe { transmute(packusdw(a.as_i32x8(), b.as_i32x8())) }
2364}
2365
2366#[inline]
2373#[target_feature(enable = "avx2")]
2374#[cfg_attr(test, assert_instr(vpermps))]
2375#[stable(feature = "simd_x86", since = "1.27.0")]
2376pub fn _mm256_permutevar8x32_epi32(a: __m256i, b: __m256i) -> __m256i {
2377 unsafe { transmute(permd(a.as_u32x8(), b.as_u32x8())) }
2378}
2379
2380#[inline]
2384#[target_feature(enable = "avx2")]
2385#[cfg_attr(test, assert_instr(vpermpd, IMM8 = 9))]
2386#[rustc_legacy_const_generics(1)]
2387#[stable(feature = "simd_x86", since = "1.27.0")]
2388#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2389pub const fn _mm256_permute4x64_epi64<const IMM8: i32>(a: __m256i) -> __m256i {
2390 static_assert_uimm_bits!(IMM8, 8);
2391 unsafe {
2392 let zero = i64x4::ZERO;
2393 let r: i64x4 = simd_shuffle!(
2394 a.as_i64x4(),
2395 zero,
2396 [
2397 IMM8 as u32 & 0b11,
2398 (IMM8 as u32 >> 2) & 0b11,
2399 (IMM8 as u32 >> 4) & 0b11,
2400 (IMM8 as u32 >> 6) & 0b11,
2401 ],
2402 );
2403 transmute(r)
2404 }
2405}
2406
2407#[inline]
2411#[target_feature(enable = "avx2")]
2412#[cfg_attr(test, assert_instr(vperm2f128, IMM8 = 9))]
2413#[rustc_legacy_const_generics(2)]
2414#[stable(feature = "simd_x86", since = "1.27.0")]
2415#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2416pub const fn _mm256_permute2x128_si256<const IMM8: i32>(a: __m256i, b: __m256i) -> __m256i {
2417 static_assert_uimm_bits!(IMM8, 8);
2418 _mm256_permute2f128_si256::<IMM8>(a, b)
2419}
2420
2421#[inline]
2426#[target_feature(enable = "avx2")]
2427#[cfg_attr(test, assert_instr(vpermpd, IMM8 = 1))]
2428#[rustc_legacy_const_generics(1)]
2429#[stable(feature = "simd_x86", since = "1.27.0")]
2430#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2431pub const fn _mm256_permute4x64_pd<const IMM8: i32>(a: __m256d) -> __m256d {
2432 static_assert_uimm_bits!(IMM8, 8);
2433 unsafe {
2434 simd_shuffle!(
2435 a,
2436 _mm256_undefined_pd(),
2437 [
2438 IMM8 as u32 & 0b11,
2439 (IMM8 as u32 >> 2) & 0b11,
2440 (IMM8 as u32 >> 4) & 0b11,
2441 (IMM8 as u32 >> 6) & 0b11,
2442 ],
2443 )
2444 }
2445}
2446
2447#[inline]
2452#[target_feature(enable = "avx2")]
2453#[cfg_attr(test, assert_instr(vpermps))]
2454#[stable(feature = "simd_x86", since = "1.27.0")]
2455pub fn _mm256_permutevar8x32_ps(a: __m256, idx: __m256i) -> __m256 {
2456 unsafe { permps(a, idx.as_i32x8()) }
2457}
2458
2459#[inline]
2466#[target_feature(enable = "avx2")]
2467#[cfg_attr(test, assert_instr(vpsadbw))]
2468#[stable(feature = "simd_x86", since = "1.27.0")]
2469pub fn _mm256_sad_epu8(a: __m256i, b: __m256i) -> __m256i {
2470 unsafe { transmute(psadbw(a.as_u8x32(), b.as_u8x32())) }
2471}
2472
2473#[inline]
2504#[target_feature(enable = "avx2")]
2505#[cfg_attr(test, assert_instr(vpshufb))]
2506#[stable(feature = "simd_x86", since = "1.27.0")]
2507pub fn _mm256_shuffle_epi8(a: __m256i, b: __m256i) -> __m256i {
2508 unsafe { transmute(pshufb(a.as_u8x32(), b.as_u8x32())) }
2509}
2510
2511#[inline]
2542#[target_feature(enable = "avx2")]
2543#[cfg_attr(test, assert_instr(vshufps, MASK = 9))]
2544#[rustc_legacy_const_generics(1)]
2545#[stable(feature = "simd_x86", since = "1.27.0")]
2546#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2547pub const fn _mm256_shuffle_epi32<const MASK: i32>(a: __m256i) -> __m256i {
2548 static_assert_uimm_bits!(MASK, 8);
2549 unsafe {
2550 let r: i32x8 = simd_shuffle!(
2551 a.as_i32x8(),
2552 a.as_i32x8(),
2553 [
2554 MASK as u32 & 0b11,
2555 (MASK as u32 >> 2) & 0b11,
2556 (MASK as u32 >> 4) & 0b11,
2557 (MASK as u32 >> 6) & 0b11,
2558 (MASK as u32 & 0b11) + 4,
2559 ((MASK as u32 >> 2) & 0b11) + 4,
2560 ((MASK as u32 >> 4) & 0b11) + 4,
2561 ((MASK as u32 >> 6) & 0b11) + 4,
2562 ],
2563 );
2564 transmute(r)
2565 }
2566}
2567
2568#[inline]
2574#[target_feature(enable = "avx2")]
2575#[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 9))]
2576#[rustc_legacy_const_generics(1)]
2577#[stable(feature = "simd_x86", since = "1.27.0")]
2578#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2579pub const fn _mm256_shufflehi_epi16<const IMM8: i32>(a: __m256i) -> __m256i {
2580 static_assert_uimm_bits!(IMM8, 8);
2581 unsafe {
2582 let a = a.as_i16x16();
2583 let r: i16x16 = simd_shuffle!(
2584 a,
2585 a,
2586 [
2587 0,
2588 1,
2589 2,
2590 3,
2591 4 + (IMM8 as u32 & 0b11),
2592 4 + ((IMM8 as u32 >> 2) & 0b11),
2593 4 + ((IMM8 as u32 >> 4) & 0b11),
2594 4 + ((IMM8 as u32 >> 6) & 0b11),
2595 8,
2596 9,
2597 10,
2598 11,
2599 12 + (IMM8 as u32 & 0b11),
2600 12 + ((IMM8 as u32 >> 2) & 0b11),
2601 12 + ((IMM8 as u32 >> 4) & 0b11),
2602 12 + ((IMM8 as u32 >> 6) & 0b11),
2603 ],
2604 );
2605 transmute(r)
2606 }
2607}
2608
2609#[inline]
2615#[target_feature(enable = "avx2")]
2616#[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 9))]
2617#[rustc_legacy_const_generics(1)]
2618#[stable(feature = "simd_x86", since = "1.27.0")]
2619#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2620pub const fn _mm256_shufflelo_epi16<const IMM8: i32>(a: __m256i) -> __m256i {
2621 static_assert_uimm_bits!(IMM8, 8);
2622 unsafe {
2623 let a = a.as_i16x16();
2624 let r: i16x16 = simd_shuffle!(
2625 a,
2626 a,
2627 [
2628 0 + (IMM8 as u32 & 0b11),
2629 0 + ((IMM8 as u32 >> 2) & 0b11),
2630 0 + ((IMM8 as u32 >> 4) & 0b11),
2631 0 + ((IMM8 as u32 >> 6) & 0b11),
2632 4,
2633 5,
2634 6,
2635 7,
2636 8 + (IMM8 as u32 & 0b11),
2637 8 + ((IMM8 as u32 >> 2) & 0b11),
2638 8 + ((IMM8 as u32 >> 4) & 0b11),
2639 8 + ((IMM8 as u32 >> 6) & 0b11),
2640 12,
2641 13,
2642 14,
2643 15,
2644 ],
2645 );
2646 transmute(r)
2647 }
2648}
2649
2650#[inline]
2656#[target_feature(enable = "avx2")]
2657#[cfg_attr(test, assert_instr(vpsignw))]
2658#[stable(feature = "simd_x86", since = "1.27.0")]
2659pub fn _mm256_sign_epi16(a: __m256i, b: __m256i) -> __m256i {
2660 unsafe { transmute(psignw(a.as_i16x16(), b.as_i16x16())) }
2661}
2662
2663#[inline]
2669#[target_feature(enable = "avx2")]
2670#[cfg_attr(test, assert_instr(vpsignd))]
2671#[stable(feature = "simd_x86", since = "1.27.0")]
2672pub fn _mm256_sign_epi32(a: __m256i, b: __m256i) -> __m256i {
2673 unsafe { transmute(psignd(a.as_i32x8(), b.as_i32x8())) }
2674}
2675
2676#[inline]
2682#[target_feature(enable = "avx2")]
2683#[cfg_attr(test, assert_instr(vpsignb))]
2684#[stable(feature = "simd_x86", since = "1.27.0")]
2685pub fn _mm256_sign_epi8(a: __m256i, b: __m256i) -> __m256i {
2686 unsafe { transmute(psignb(a.as_i8x32(), b.as_i8x32())) }
2687}
2688
2689#[inline]
2694#[target_feature(enable = "avx2")]
2695#[cfg_attr(test, assert_instr(vpsllw))]
2696#[stable(feature = "simd_x86", since = "1.27.0")]
2697pub fn _mm256_sll_epi16(a: __m256i, count: __m128i) -> __m256i {
2698 unsafe { transmute(psllw(a.as_i16x16(), count.as_i16x8())) }
2699}
2700
2701#[inline]
2706#[target_feature(enable = "avx2")]
2707#[cfg_attr(test, assert_instr(vpslld))]
2708#[stable(feature = "simd_x86", since = "1.27.0")]
2709pub fn _mm256_sll_epi32(a: __m256i, count: __m128i) -> __m256i {
2710 unsafe { transmute(pslld(a.as_i32x8(), count.as_i32x4())) }
2711}
2712
2713#[inline]
2718#[target_feature(enable = "avx2")]
2719#[cfg_attr(test, assert_instr(vpsllq))]
2720#[stable(feature = "simd_x86", since = "1.27.0")]
2721pub fn _mm256_sll_epi64(a: __m256i, count: __m128i) -> __m256i {
2722 unsafe { transmute(psllq(a.as_i64x4(), count.as_i64x2())) }
2723}
2724
2725#[inline]
2730#[target_feature(enable = "avx2")]
2731#[cfg_attr(test, assert_instr(vpsllw, IMM8 = 7))]
2732#[rustc_legacy_const_generics(1)]
2733#[stable(feature = "simd_x86", since = "1.27.0")]
2734#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2735pub const fn _mm256_slli_epi16<const IMM8: i32>(a: __m256i) -> __m256i {
2736 static_assert_uimm_bits!(IMM8, 8);
2737 unsafe {
2738 if IMM8 >= 16 {
2739 _mm256_setzero_si256()
2740 } else {
2741 transmute(simd_shl(a.as_u16x16(), u16x16::splat(IMM8 as u16)))
2742 }
2743 }
2744}
2745
2746#[inline]
2751#[target_feature(enable = "avx2")]
2752#[cfg_attr(test, assert_instr(vpslld, IMM8 = 7))]
2753#[rustc_legacy_const_generics(1)]
2754#[stable(feature = "simd_x86", since = "1.27.0")]
2755#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2756pub const fn _mm256_slli_epi32<const IMM8: i32>(a: __m256i) -> __m256i {
2757 unsafe {
2758 static_assert_uimm_bits!(IMM8, 8);
2759 if IMM8 >= 32 {
2760 _mm256_setzero_si256()
2761 } else {
2762 transmute(simd_shl(a.as_u32x8(), u32x8::splat(IMM8 as u32)))
2763 }
2764 }
2765}
2766
2767#[inline]
2772#[target_feature(enable = "avx2")]
2773#[cfg_attr(test, assert_instr(vpsllq, IMM8 = 7))]
2774#[rustc_legacy_const_generics(1)]
2775#[stable(feature = "simd_x86", since = "1.27.0")]
2776#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2777pub const fn _mm256_slli_epi64<const IMM8: i32>(a: __m256i) -> __m256i {
2778 unsafe {
2779 static_assert_uimm_bits!(IMM8, 8);
2780 if IMM8 >= 64 {
2781 _mm256_setzero_si256()
2782 } else {
2783 transmute(simd_shl(a.as_u64x4(), u64x4::splat(IMM8 as u64)))
2784 }
2785 }
2786}
2787
2788#[inline]
2792#[target_feature(enable = "avx2")]
2793#[cfg_attr(test, assert_instr(vpslldq, IMM8 = 3))]
2794#[rustc_legacy_const_generics(1)]
2795#[stable(feature = "simd_x86", since = "1.27.0")]
2796#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2797pub const fn _mm256_slli_si256<const IMM8: i32>(a: __m256i) -> __m256i {
2798 static_assert_uimm_bits!(IMM8, 8);
2799 _mm256_bslli_epi128::<IMM8>(a)
2800}
2801
2802#[inline]
2806#[target_feature(enable = "avx2")]
2807#[cfg_attr(test, assert_instr(vpslldq, IMM8 = 3))]
2808#[rustc_legacy_const_generics(1)]
2809#[stable(feature = "simd_x86", since = "1.27.0")]
2810#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2811pub const fn _mm256_bslli_epi128<const IMM8: i32>(a: __m256i) -> __m256i {
2812 static_assert_uimm_bits!(IMM8, 8);
2813 const fn mask(shift: i32, i: u32) -> u32 {
2814 let shift = shift as u32 & 0xff;
2815 if shift > 15 || i % 16 < shift {
2816 0
2817 } else {
2818 32 + (i - shift)
2819 }
2820 }
2821 unsafe {
2822 let a = a.as_i8x32();
2823 let r: i8x32 = simd_shuffle!(
2824 i8x32::ZERO,
2825 a,
2826 [
2827 mask(IMM8, 0),
2828 mask(IMM8, 1),
2829 mask(IMM8, 2),
2830 mask(IMM8, 3),
2831 mask(IMM8, 4),
2832 mask(IMM8, 5),
2833 mask(IMM8, 6),
2834 mask(IMM8, 7),
2835 mask(IMM8, 8),
2836 mask(IMM8, 9),
2837 mask(IMM8, 10),
2838 mask(IMM8, 11),
2839 mask(IMM8, 12),
2840 mask(IMM8, 13),
2841 mask(IMM8, 14),
2842 mask(IMM8, 15),
2843 mask(IMM8, 16),
2844 mask(IMM8, 17),
2845 mask(IMM8, 18),
2846 mask(IMM8, 19),
2847 mask(IMM8, 20),
2848 mask(IMM8, 21),
2849 mask(IMM8, 22),
2850 mask(IMM8, 23),
2851 mask(IMM8, 24),
2852 mask(IMM8, 25),
2853 mask(IMM8, 26),
2854 mask(IMM8, 27),
2855 mask(IMM8, 28),
2856 mask(IMM8, 29),
2857 mask(IMM8, 30),
2858 mask(IMM8, 31),
2859 ],
2860 );
2861 transmute(r)
2862 }
2863}
2864
2865#[inline]
2871#[target_feature(enable = "avx2")]
2872#[cfg_attr(test, assert_instr(vpsllvd))]
2873#[stable(feature = "simd_x86", since = "1.27.0")]
2874pub fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i {
2875 unsafe { transmute(psllvd(a.as_i32x4(), count.as_i32x4())) }
2876}
2877
2878#[inline]
2884#[target_feature(enable = "avx2")]
2885#[cfg_attr(test, assert_instr(vpsllvd))]
2886#[stable(feature = "simd_x86", since = "1.27.0")]
2887pub fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i {
2888 unsafe { transmute(psllvd256(a.as_i32x8(), count.as_i32x8())) }
2889}
2890
2891#[inline]
2897#[target_feature(enable = "avx2")]
2898#[cfg_attr(test, assert_instr(vpsllvq))]
2899#[stable(feature = "simd_x86", since = "1.27.0")]
2900pub fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i {
2901 unsafe { transmute(psllvq(a.as_i64x2(), count.as_i64x2())) }
2902}
2903
2904#[inline]
2910#[target_feature(enable = "avx2")]
2911#[cfg_attr(test, assert_instr(vpsllvq))]
2912#[stable(feature = "simd_x86", since = "1.27.0")]
2913pub fn _mm256_sllv_epi64(a: __m256i, count: __m256i) -> __m256i {
2914 unsafe { transmute(psllvq256(a.as_i64x4(), count.as_i64x4())) }
2915}
2916
2917#[inline]
2922#[target_feature(enable = "avx2")]
2923#[cfg_attr(test, assert_instr(vpsraw))]
2924#[stable(feature = "simd_x86", since = "1.27.0")]
2925pub fn _mm256_sra_epi16(a: __m256i, count: __m128i) -> __m256i {
2926 unsafe { transmute(psraw(a.as_i16x16(), count.as_i16x8())) }
2927}
2928
2929#[inline]
2934#[target_feature(enable = "avx2")]
2935#[cfg_attr(test, assert_instr(vpsrad))]
2936#[stable(feature = "simd_x86", since = "1.27.0")]
2937pub fn _mm256_sra_epi32(a: __m256i, count: __m128i) -> __m256i {
2938 unsafe { transmute(psrad(a.as_i32x8(), count.as_i32x4())) }
2939}
2940
2941#[inline]
2946#[target_feature(enable = "avx2")]
2947#[cfg_attr(test, assert_instr(vpsraw, IMM8 = 7))]
2948#[rustc_legacy_const_generics(1)]
2949#[stable(feature = "simd_x86", since = "1.27.0")]
2950#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2951pub const fn _mm256_srai_epi16<const IMM8: i32>(a: __m256i) -> __m256i {
2952 static_assert_uimm_bits!(IMM8, 8);
2953 unsafe { transmute(simd_shr(a.as_i16x16(), i16x16::splat(IMM8.min(15) as i16))) }
2954}
2955
2956#[inline]
2961#[target_feature(enable = "avx2")]
2962#[cfg_attr(test, assert_instr(vpsrad, IMM8 = 7))]
2963#[rustc_legacy_const_generics(1)]
2964#[stable(feature = "simd_x86", since = "1.27.0")]
2965#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2966pub const fn _mm256_srai_epi32<const IMM8: i32>(a: __m256i) -> __m256i {
2967 static_assert_uimm_bits!(IMM8, 8);
2968 unsafe { transmute(simd_shr(a.as_i32x8(), i32x8::splat(IMM8.min(31)))) }
2969}
2970
2971#[inline]
2976#[target_feature(enable = "avx2")]
2977#[cfg_attr(test, assert_instr(vpsravd))]
2978#[stable(feature = "simd_x86", since = "1.27.0")]
2979pub fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i {
2980 unsafe { transmute(psravd(a.as_i32x4(), count.as_i32x4())) }
2981}
2982
2983#[inline]
2988#[target_feature(enable = "avx2")]
2989#[cfg_attr(test, assert_instr(vpsravd))]
2990#[stable(feature = "simd_x86", since = "1.27.0")]
2991pub fn _mm256_srav_epi32(a: __m256i, count: __m256i) -> __m256i {
2992 unsafe { transmute(psravd256(a.as_i32x8(), count.as_i32x8())) }
2993}
2994
2995#[inline]
2999#[target_feature(enable = "avx2")]
3000#[cfg_attr(test, assert_instr(vpsrldq, IMM8 = 1))]
3001#[rustc_legacy_const_generics(1)]
3002#[stable(feature = "simd_x86", since = "1.27.0")]
3003#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3004pub const fn _mm256_srli_si256<const IMM8: i32>(a: __m256i) -> __m256i {
3005 static_assert_uimm_bits!(IMM8, 8);
3006 _mm256_bsrli_epi128::<IMM8>(a)
3007}
3008
3009#[inline]
3013#[target_feature(enable = "avx2")]
3014#[cfg_attr(test, assert_instr(vpsrldq, IMM8 = 1))]
3015#[rustc_legacy_const_generics(1)]
3016#[stable(feature = "simd_x86", since = "1.27.0")]
3017#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3018pub const fn _mm256_bsrli_epi128<const IMM8: i32>(a: __m256i) -> __m256i {
3019 static_assert_uimm_bits!(IMM8, 8);
3020 const fn mask(shift: i32, i: u32) -> u32 {
3021 let shift = shift as u32 & 0xff;
3022 if shift > 15 || (15 - (i % 16)) < shift {
3023 0
3024 } else {
3025 32 + (i + shift)
3026 }
3027 }
3028 unsafe {
3029 let a = a.as_i8x32();
3030 let r: i8x32 = simd_shuffle!(
3031 i8x32::ZERO,
3032 a,
3033 [
3034 mask(IMM8, 0),
3035 mask(IMM8, 1),
3036 mask(IMM8, 2),
3037 mask(IMM8, 3),
3038 mask(IMM8, 4),
3039 mask(IMM8, 5),
3040 mask(IMM8, 6),
3041 mask(IMM8, 7),
3042 mask(IMM8, 8),
3043 mask(IMM8, 9),
3044 mask(IMM8, 10),
3045 mask(IMM8, 11),
3046 mask(IMM8, 12),
3047 mask(IMM8, 13),
3048 mask(IMM8, 14),
3049 mask(IMM8, 15),
3050 mask(IMM8, 16),
3051 mask(IMM8, 17),
3052 mask(IMM8, 18),
3053 mask(IMM8, 19),
3054 mask(IMM8, 20),
3055 mask(IMM8, 21),
3056 mask(IMM8, 22),
3057 mask(IMM8, 23),
3058 mask(IMM8, 24),
3059 mask(IMM8, 25),
3060 mask(IMM8, 26),
3061 mask(IMM8, 27),
3062 mask(IMM8, 28),
3063 mask(IMM8, 29),
3064 mask(IMM8, 30),
3065 mask(IMM8, 31),
3066 ],
3067 );
3068 transmute(r)
3069 }
3070}
3071
3072#[inline]
3077#[target_feature(enable = "avx2")]
3078#[cfg_attr(test, assert_instr(vpsrlw))]
3079#[stable(feature = "simd_x86", since = "1.27.0")]
3080pub fn _mm256_srl_epi16(a: __m256i, count: __m128i) -> __m256i {
3081 unsafe { transmute(psrlw(a.as_i16x16(), count.as_i16x8())) }
3082}
3083
3084#[inline]
3089#[target_feature(enable = "avx2")]
3090#[cfg_attr(test, assert_instr(vpsrld))]
3091#[stable(feature = "simd_x86", since = "1.27.0")]
3092pub fn _mm256_srl_epi32(a: __m256i, count: __m128i) -> __m256i {
3093 unsafe { transmute(psrld(a.as_i32x8(), count.as_i32x4())) }
3094}
3095
3096#[inline]
3101#[target_feature(enable = "avx2")]
3102#[cfg_attr(test, assert_instr(vpsrlq))]
3103#[stable(feature = "simd_x86", since = "1.27.0")]
3104pub fn _mm256_srl_epi64(a: __m256i, count: __m128i) -> __m256i {
3105 unsafe { transmute(psrlq(a.as_i64x4(), count.as_i64x2())) }
3106}
3107
3108#[inline]
3113#[target_feature(enable = "avx2")]
3114#[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 7))]
3115#[rustc_legacy_const_generics(1)]
3116#[stable(feature = "simd_x86", since = "1.27.0")]
3117#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3118pub const fn _mm256_srli_epi16<const IMM8: i32>(a: __m256i) -> __m256i {
3119 static_assert_uimm_bits!(IMM8, 8);
3120 unsafe {
3121 if IMM8 >= 16 {
3122 _mm256_setzero_si256()
3123 } else {
3124 transmute(simd_shr(a.as_u16x16(), u16x16::splat(IMM8 as u16)))
3125 }
3126 }
3127}
3128
3129#[inline]
3134#[target_feature(enable = "avx2")]
3135#[cfg_attr(test, assert_instr(vpsrld, IMM8 = 7))]
3136#[rustc_legacy_const_generics(1)]
3137#[stable(feature = "simd_x86", since = "1.27.0")]
3138#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3139pub const fn _mm256_srli_epi32<const IMM8: i32>(a: __m256i) -> __m256i {
3140 static_assert_uimm_bits!(IMM8, 8);
3141 unsafe {
3142 if IMM8 >= 32 {
3143 _mm256_setzero_si256()
3144 } else {
3145 transmute(simd_shr(a.as_u32x8(), u32x8::splat(IMM8 as u32)))
3146 }
3147 }
3148}
3149
3150#[inline]
3155#[target_feature(enable = "avx2")]
3156#[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 7))]
3157#[rustc_legacy_const_generics(1)]
3158#[stable(feature = "simd_x86", since = "1.27.0")]
3159#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3160pub const fn _mm256_srli_epi64<const IMM8: i32>(a: __m256i) -> __m256i {
3161 static_assert_uimm_bits!(IMM8, 8);
3162 unsafe {
3163 if IMM8 >= 64 {
3164 _mm256_setzero_si256()
3165 } else {
3166 transmute(simd_shr(a.as_u64x4(), u64x4::splat(IMM8 as u64)))
3167 }
3168 }
3169}
3170
3171#[inline]
3176#[target_feature(enable = "avx2")]
3177#[cfg_attr(test, assert_instr(vpsrlvd))]
3178#[stable(feature = "simd_x86", since = "1.27.0")]
3179pub fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i {
3180 unsafe { transmute(psrlvd(a.as_i32x4(), count.as_i32x4())) }
3181}
3182
3183#[inline]
3188#[target_feature(enable = "avx2")]
3189#[cfg_attr(test, assert_instr(vpsrlvd))]
3190#[stable(feature = "simd_x86", since = "1.27.0")]
3191pub fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i {
3192 unsafe { transmute(psrlvd256(a.as_i32x8(), count.as_i32x8())) }
3193}
3194
3195#[inline]
3200#[target_feature(enable = "avx2")]
3201#[cfg_attr(test, assert_instr(vpsrlvq))]
3202#[stable(feature = "simd_x86", since = "1.27.0")]
3203pub fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i {
3204 unsafe { transmute(psrlvq(a.as_i64x2(), count.as_i64x2())) }
3205}
3206
3207#[inline]
3212#[target_feature(enable = "avx2")]
3213#[cfg_attr(test, assert_instr(vpsrlvq))]
3214#[stable(feature = "simd_x86", since = "1.27.0")]
3215pub fn _mm256_srlv_epi64(a: __m256i, count: __m256i) -> __m256i {
3216 unsafe { transmute(psrlvq256(a.as_i64x4(), count.as_i64x4())) }
3217}
3218
3219#[inline]
3225#[target_feature(enable = "avx2")]
3226#[cfg_attr(test, assert_instr(vmovntdqa))]
3227#[stable(feature = "simd_x86_updates", since = "1.82.0")]
3228pub unsafe fn _mm256_stream_load_si256(mem_addr: *const __m256i) -> __m256i {
3229 let dst: __m256i;
3230 crate::arch::asm!(
3231 vpl!("vmovntdqa {a}"),
3232 a = out(ymm_reg) dst,
3233 p = in(reg) mem_addr,
3234 options(pure, readonly, nostack, preserves_flags),
3235 );
3236 dst
3237}
3238
3239#[inline]
3243#[target_feature(enable = "avx2")]
3244#[cfg_attr(test, assert_instr(vpsubw))]
3245#[stable(feature = "simd_x86", since = "1.27.0")]
3246#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3247pub const fn _mm256_sub_epi16(a: __m256i, b: __m256i) -> __m256i {
3248 unsafe { transmute(simd_sub(a.as_i16x16(), b.as_i16x16())) }
3249}
3250
3251#[inline]
3255#[target_feature(enable = "avx2")]
3256#[cfg_attr(test, assert_instr(vpsubd))]
3257#[stable(feature = "simd_x86", since = "1.27.0")]
3258#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3259pub const fn _mm256_sub_epi32(a: __m256i, b: __m256i) -> __m256i {
3260 unsafe { transmute(simd_sub(a.as_i32x8(), b.as_i32x8())) }
3261}
3262
3263#[inline]
3267#[target_feature(enable = "avx2")]
3268#[cfg_attr(test, assert_instr(vpsubq))]
3269#[stable(feature = "simd_x86", since = "1.27.0")]
3270#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3271pub const fn _mm256_sub_epi64(a: __m256i, b: __m256i) -> __m256i {
3272 unsafe { transmute(simd_sub(a.as_i64x4(), b.as_i64x4())) }
3273}
3274
3275#[inline]
3279#[target_feature(enable = "avx2")]
3280#[cfg_attr(test, assert_instr(vpsubb))]
3281#[stable(feature = "simd_x86", since = "1.27.0")]
3282#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3283pub const fn _mm256_sub_epi8(a: __m256i, b: __m256i) -> __m256i {
3284 unsafe { transmute(simd_sub(a.as_i8x32(), b.as_i8x32())) }
3285}
3286
3287#[inline]
3292#[target_feature(enable = "avx2")]
3293#[cfg_attr(test, assert_instr(vpsubsw))]
3294#[stable(feature = "simd_x86", since = "1.27.0")]
3295#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3296pub const fn _mm256_subs_epi16(a: __m256i, b: __m256i) -> __m256i {
3297 unsafe { transmute(simd_saturating_sub(a.as_i16x16(), b.as_i16x16())) }
3298}
3299
3300#[inline]
3305#[target_feature(enable = "avx2")]
3306#[cfg_attr(test, assert_instr(vpsubsb))]
3307#[stable(feature = "simd_x86", since = "1.27.0")]
3308#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3309pub const fn _mm256_subs_epi8(a: __m256i, b: __m256i) -> __m256i {
3310 unsafe { transmute(simd_saturating_sub(a.as_i8x32(), b.as_i8x32())) }
3311}
3312
3313#[inline]
3318#[target_feature(enable = "avx2")]
3319#[cfg_attr(test, assert_instr(vpsubusw))]
3320#[stable(feature = "simd_x86", since = "1.27.0")]
3321#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3322pub const fn _mm256_subs_epu16(a: __m256i, b: __m256i) -> __m256i {
3323 unsafe { transmute(simd_saturating_sub(a.as_u16x16(), b.as_u16x16())) }
3324}
3325
3326#[inline]
3331#[target_feature(enable = "avx2")]
3332#[cfg_attr(test, assert_instr(vpsubusb))]
3333#[stable(feature = "simd_x86", since = "1.27.0")]
3334#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3335pub const fn _mm256_subs_epu8(a: __m256i, b: __m256i) -> __m256i {
3336 unsafe { transmute(simd_saturating_sub(a.as_u8x32(), b.as_u8x32())) }
3337}
3338
3339#[inline]
3379#[target_feature(enable = "avx2")]
3380#[cfg_attr(test, assert_instr(vpunpckhbw))]
3381#[stable(feature = "simd_x86", since = "1.27.0")]
3382#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3383pub const fn _mm256_unpackhi_epi8(a: __m256i, b: __m256i) -> __m256i {
3384 unsafe {
3385 #[rustfmt::skip]
3386 let r: i8x32 = simd_shuffle!(a.as_i8x32(), b.as_i8x32(), [
3387 8, 40, 9, 41, 10, 42, 11, 43,
3388 12, 44, 13, 45, 14, 46, 15, 47,
3389 24, 56, 25, 57, 26, 58, 27, 59,
3390 28, 60, 29, 61, 30, 62, 31, 63,
3391 ]);
3392 transmute(r)
3393 }
3394}
3395
3396#[inline]
3435#[target_feature(enable = "avx2")]
3436#[cfg_attr(test, assert_instr(vpunpcklbw))]
3437#[stable(feature = "simd_x86", since = "1.27.0")]
3438#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3439pub const fn _mm256_unpacklo_epi8(a: __m256i, b: __m256i) -> __m256i {
3440 unsafe {
3441 #[rustfmt::skip]
3442 let r: i8x32 = simd_shuffle!(a.as_i8x32(), b.as_i8x32(), [
3443 0, 32, 1, 33, 2, 34, 3, 35,
3444 4, 36, 5, 37, 6, 38, 7, 39,
3445 16, 48, 17, 49, 18, 50, 19, 51,
3446 20, 52, 21, 53, 22, 54, 23, 55,
3447 ]);
3448 transmute(r)
3449 }
3450}
3451
3452#[inline]
3487#[target_feature(enable = "avx2")]
3488#[cfg_attr(test, assert_instr(vpunpckhwd))]
3489#[stable(feature = "simd_x86", since = "1.27.0")]
3490#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3491pub const fn _mm256_unpackhi_epi16(a: __m256i, b: __m256i) -> __m256i {
3492 unsafe {
3493 let r: i16x16 = simd_shuffle!(
3494 a.as_i16x16(),
3495 b.as_i16x16(),
3496 [4, 20, 5, 21, 6, 22, 7, 23, 12, 28, 13, 29, 14, 30, 15, 31],
3497 );
3498 transmute(r)
3499 }
3500}
3501
3502#[inline]
3538#[target_feature(enable = "avx2")]
3539#[cfg_attr(test, assert_instr(vpunpcklwd))]
3540#[stable(feature = "simd_x86", since = "1.27.0")]
3541#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3542pub const fn _mm256_unpacklo_epi16(a: __m256i, b: __m256i) -> __m256i {
3543 unsafe {
3544 let r: i16x16 = simd_shuffle!(
3545 a.as_i16x16(),
3546 b.as_i16x16(),
3547 [0, 16, 1, 17, 2, 18, 3, 19, 8, 24, 9, 25, 10, 26, 11, 27],
3548 );
3549 transmute(r)
3550 }
3551}
3552
3553#[inline]
3582#[target_feature(enable = "avx2")]
3583#[cfg_attr(test, assert_instr(vunpckhps))]
3584#[stable(feature = "simd_x86", since = "1.27.0")]
3585#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3586pub const fn _mm256_unpackhi_epi32(a: __m256i, b: __m256i) -> __m256i {
3587 unsafe {
3588 let r: i32x8 = simd_shuffle!(a.as_i32x8(), b.as_i32x8(), [2, 10, 3, 11, 6, 14, 7, 15]);
3589 transmute(r)
3590 }
3591}
3592
3593#[inline]
3622#[target_feature(enable = "avx2")]
3623#[cfg_attr(test, assert_instr(vunpcklps))]
3624#[stable(feature = "simd_x86", since = "1.27.0")]
3625#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3626pub const fn _mm256_unpacklo_epi32(a: __m256i, b: __m256i) -> __m256i {
3627 unsafe {
3628 let r: i32x8 = simd_shuffle!(a.as_i32x8(), b.as_i32x8(), [0, 8, 1, 9, 4, 12, 5, 13]);
3629 transmute(r)
3630 }
3631}
3632
3633#[inline]
3662#[target_feature(enable = "avx2")]
3663#[cfg_attr(test, assert_instr(vunpckhpd))]
3664#[stable(feature = "simd_x86", since = "1.27.0")]
3665#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3666pub const fn _mm256_unpackhi_epi64(a: __m256i, b: __m256i) -> __m256i {
3667 unsafe {
3668 let r: i64x4 = simd_shuffle!(a.as_i64x4(), b.as_i64x4(), [1, 5, 3, 7]);
3669 transmute(r)
3670 }
3671}
3672
3673#[inline]
3702#[target_feature(enable = "avx2")]
3703#[cfg_attr(test, assert_instr(vunpcklpd))]
3704#[stable(feature = "simd_x86", since = "1.27.0")]
3705#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3706pub const fn _mm256_unpacklo_epi64(a: __m256i, b: __m256i) -> __m256i {
3707 unsafe {
3708 let r: i64x4 = simd_shuffle!(a.as_i64x4(), b.as_i64x4(), [0, 4, 2, 6]);
3709 transmute(r)
3710 }
3711}
3712
3713#[inline]
3718#[target_feature(enable = "avx2")]
3719#[cfg_attr(test, assert_instr(vxorps))]
3720#[stable(feature = "simd_x86", since = "1.27.0")]
3721#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3722pub const fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i {
3723 unsafe { transmute(simd_xor(a.as_i64x4(), b.as_i64x4())) }
3724}
3725
3726#[inline]
3733#[target_feature(enable = "avx2")]
3734#[rustc_legacy_const_generics(1)]
3736#[stable(feature = "simd_x86", since = "1.27.0")]
3737#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3738pub const fn _mm256_extract_epi8<const INDEX: i32>(a: __m256i) -> i32 {
3739 static_assert_uimm_bits!(INDEX, 5);
3740 unsafe { simd_extract!(a.as_u8x32(), INDEX as u32, u8) as i32 }
3741}
3742
3743#[inline]
3750#[target_feature(enable = "avx2")]
3751#[rustc_legacy_const_generics(1)]
3753#[stable(feature = "simd_x86", since = "1.27.0")]
3754#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3755pub const fn _mm256_extract_epi16<const INDEX: i32>(a: __m256i) -> i32 {
3756 static_assert_uimm_bits!(INDEX, 4);
3757 unsafe { simd_extract!(a.as_u16x16(), INDEX as u32, u16) as i32 }
3758}
3759
3760#[allow(improper_ctypes)]
3761unsafe extern "llvm-intrinsic" {
3762 #[link_name = "llvm.x86.avx2.pmadd.wd"]
3763 fn pmaddwd(a: i16x16, b: i16x16) -> i32x8;
3764 #[link_name = "llvm.x86.avx2.pmadd.ub.sw"]
3765 fn pmaddubsw(a: u8x32, b: i8x32) -> i16x16;
3766 #[link_name = "llvm.x86.avx2.mpsadbw"]
3767 fn mpsadbw(a: u8x32, b: u8x32, imm8: i8) -> u16x16;
3768 #[link_name = "llvm.x86.avx2.pmul.hr.sw"]
3769 fn pmulhrsw(a: i16x16, b: i16x16) -> i16x16;
3770 #[link_name = "llvm.x86.avx2.packsswb"]
3771 fn packsswb(a: i16x16, b: i16x16) -> i8x32;
3772 #[link_name = "llvm.x86.avx2.packssdw"]
3773 fn packssdw(a: i32x8, b: i32x8) -> i16x16;
3774 #[link_name = "llvm.x86.avx2.packuswb"]
3775 fn packuswb(a: i16x16, b: i16x16) -> u8x32;
3776 #[link_name = "llvm.x86.avx2.packusdw"]
3777 fn packusdw(a: i32x8, b: i32x8) -> u16x16;
3778 #[link_name = "llvm.x86.avx2.psad.bw"]
3779 fn psadbw(a: u8x32, b: u8x32) -> u64x4;
3780 #[link_name = "llvm.x86.avx2.psign.b"]
3781 fn psignb(a: i8x32, b: i8x32) -> i8x32;
3782 #[link_name = "llvm.x86.avx2.psign.w"]
3783 fn psignw(a: i16x16, b: i16x16) -> i16x16;
3784 #[link_name = "llvm.x86.avx2.psign.d"]
3785 fn psignd(a: i32x8, b: i32x8) -> i32x8;
3786 #[link_name = "llvm.x86.avx2.psll.w"]
3787 fn psllw(a: i16x16, count: i16x8) -> i16x16;
3788 #[link_name = "llvm.x86.avx2.psll.d"]
3789 fn pslld(a: i32x8, count: i32x4) -> i32x8;
3790 #[link_name = "llvm.x86.avx2.psll.q"]
3791 fn psllq(a: i64x4, count: i64x2) -> i64x4;
3792 #[link_name = "llvm.x86.avx2.psllv.d"]
3793 fn psllvd(a: i32x4, count: i32x4) -> i32x4;
3794 #[link_name = "llvm.x86.avx2.psllv.d.256"]
3795 fn psllvd256(a: i32x8, count: i32x8) -> i32x8;
3796 #[link_name = "llvm.x86.avx2.psllv.q"]
3797 fn psllvq(a: i64x2, count: i64x2) -> i64x2;
3798 #[link_name = "llvm.x86.avx2.psllv.q.256"]
3799 fn psllvq256(a: i64x4, count: i64x4) -> i64x4;
3800 #[link_name = "llvm.x86.avx2.psra.w"]
3801 fn psraw(a: i16x16, count: i16x8) -> i16x16;
3802 #[link_name = "llvm.x86.avx2.psra.d"]
3803 fn psrad(a: i32x8, count: i32x4) -> i32x8;
3804 #[link_name = "llvm.x86.avx2.psrav.d"]
3805 fn psravd(a: i32x4, count: i32x4) -> i32x4;
3806 #[link_name = "llvm.x86.avx2.psrav.d.256"]
3807 fn psravd256(a: i32x8, count: i32x8) -> i32x8;
3808 #[link_name = "llvm.x86.avx2.psrl.w"]
3809 fn psrlw(a: i16x16, count: i16x8) -> i16x16;
3810 #[link_name = "llvm.x86.avx2.psrl.d"]
3811 fn psrld(a: i32x8, count: i32x4) -> i32x8;
3812 #[link_name = "llvm.x86.avx2.psrl.q"]
3813 fn psrlq(a: i64x4, count: i64x2) -> i64x4;
3814 #[link_name = "llvm.x86.avx2.psrlv.d"]
3815 fn psrlvd(a: i32x4, count: i32x4) -> i32x4;
3816 #[link_name = "llvm.x86.avx2.psrlv.d.256"]
3817 fn psrlvd256(a: i32x8, count: i32x8) -> i32x8;
3818 #[link_name = "llvm.x86.avx2.psrlv.q"]
3819 fn psrlvq(a: i64x2, count: i64x2) -> i64x2;
3820 #[link_name = "llvm.x86.avx2.psrlv.q.256"]
3821 fn psrlvq256(a: i64x4, count: i64x4) -> i64x4;
3822 #[link_name = "llvm.x86.avx2.pshuf.b"]
3823 fn pshufb(a: u8x32, b: u8x32) -> u8x32;
3824 #[link_name = "llvm.x86.avx2.permd"]
3825 fn permd(a: u32x8, b: u32x8) -> u32x8;
3826 #[link_name = "llvm.x86.avx2.permps"]
3827 fn permps(a: __m256, b: i32x8) -> __m256;
3828 #[link_name = "llvm.x86.avx2.gather.d.d"]
3829 fn pgatherdd(src: i32x4, slice: *const i8, offsets: i32x4, mask: i32x4, scale: i8) -> i32x4;
3830 #[link_name = "llvm.x86.avx2.gather.d.d.256"]
3831 fn vpgatherdd(src: i32x8, slice: *const i8, offsets: i32x8, mask: i32x8, scale: i8) -> i32x8;
3832 #[link_name = "llvm.x86.avx2.gather.d.q"]
3833 fn pgatherdq(src: i64x2, slice: *const i8, offsets: i32x4, mask: i64x2, scale: i8) -> i64x2;
3834 #[link_name = "llvm.x86.avx2.gather.d.q.256"]
3835 fn vpgatherdq(src: i64x4, slice: *const i8, offsets: i32x4, mask: i64x4, scale: i8) -> i64x4;
3836 #[link_name = "llvm.x86.avx2.gather.q.d"]
3837 fn pgatherqd(src: i32x4, slice: *const i8, offsets: i64x2, mask: i32x4, scale: i8) -> i32x4;
3838 #[link_name = "llvm.x86.avx2.gather.q.d.256"]
3839 fn vpgatherqd(src: i32x4, slice: *const i8, offsets: i64x4, mask: i32x4, scale: i8) -> i32x4;
3840 #[link_name = "llvm.x86.avx2.gather.q.q"]
3841 fn pgatherqq(src: i64x2, slice: *const i8, offsets: i64x2, mask: i64x2, scale: i8) -> i64x2;
3842 #[link_name = "llvm.x86.avx2.gather.q.q.256"]
3843 fn vpgatherqq(src: i64x4, slice: *const i8, offsets: i64x4, mask: i64x4, scale: i8) -> i64x4;
3844 #[link_name = "llvm.x86.avx2.gather.d.pd"]
3845 fn pgatherdpd(
3846 src: __m128d,
3847 slice: *const i8,
3848 offsets: i32x4,
3849 mask: __m128d,
3850 scale: i8,
3851 ) -> __m128d;
3852 #[link_name = "llvm.x86.avx2.gather.d.pd.256"]
3853 fn vpgatherdpd(
3854 src: __m256d,
3855 slice: *const i8,
3856 offsets: i32x4,
3857 mask: __m256d,
3858 scale: i8,
3859 ) -> __m256d;
3860 #[link_name = "llvm.x86.avx2.gather.q.pd"]
3861 fn pgatherqpd(
3862 src: __m128d,
3863 slice: *const i8,
3864 offsets: i64x2,
3865 mask: __m128d,
3866 scale: i8,
3867 ) -> __m128d;
3868 #[link_name = "llvm.x86.avx2.gather.q.pd.256"]
3869 fn vpgatherqpd(
3870 src: __m256d,
3871 slice: *const i8,
3872 offsets: i64x4,
3873 mask: __m256d,
3874 scale: i8,
3875 ) -> __m256d;
3876 #[link_name = "llvm.x86.avx2.gather.d.ps"]
3877 fn pgatherdps(src: __m128, slice: *const i8, offsets: i32x4, mask: __m128, scale: i8)
3878 -> __m128;
3879 #[link_name = "llvm.x86.avx2.gather.d.ps.256"]
3880 fn vpgatherdps(
3881 src: __m256,
3882 slice: *const i8,
3883 offsets: i32x8,
3884 mask: __m256,
3885 scale: i8,
3886 ) -> __m256;
3887 #[link_name = "llvm.x86.avx2.gather.q.ps"]
3888 fn pgatherqps(src: __m128, slice: *const i8, offsets: i64x2, mask: __m128, scale: i8)
3889 -> __m128;
3890 #[link_name = "llvm.x86.avx2.gather.q.ps.256"]
3891 fn vpgatherqps(
3892 src: __m128,
3893 slice: *const i8,
3894 offsets: i64x4,
3895 mask: __m128,
3896 scale: i8,
3897 ) -> __m128;
3898}
3899
3900#[cfg(test)]
3901mod tests {
3902 use crate::core_arch::assert_eq_const as assert_eq;
3903
3904 use stdarch_test::simd_test;
3905
3906 use crate::core_arch::x86::*;
3907
3908 #[simd_test(enable = "avx2")]
3909 const fn test_mm256_abs_epi32() {
3910 #[rustfmt::skip]
3911 let a = _mm256_setr_epi32(
3912 0, 1, -1, i32::MAX,
3913 i32::MIN, 100, -100, -32,
3914 );
3915 let r = _mm256_abs_epi32(a);
3916 #[rustfmt::skip]
3917 let e = _mm256_setr_epi32(
3918 0, 1, 1, i32::MAX,
3919 i32::MAX.wrapping_add(1), 100, 100, 32,
3920 );
3921 assert_eq_m256i(r, e);
3922 }
3923
3924 #[simd_test(enable = "avx2")]
3925 const fn test_mm256_abs_epi16() {
3926 #[rustfmt::skip]
3927 let a = _mm256_setr_epi16(
3928 0, 1, -1, 2, -2, 3, -3, 4,
3929 -4, 5, -5, i16::MAX, i16::MIN, 100, -100, -32,
3930 );
3931 let r = _mm256_abs_epi16(a);
3932 #[rustfmt::skip]
3933 let e = _mm256_setr_epi16(
3934 0, 1, 1, 2, 2, 3, 3, 4,
3935 4, 5, 5, i16::MAX, i16::MAX.wrapping_add(1), 100, 100, 32,
3936 );
3937 assert_eq_m256i(r, e);
3938 }
3939
3940 #[simd_test(enable = "avx2")]
3941 const fn test_mm256_abs_epi8() {
3942 #[rustfmt::skip]
3943 let a = _mm256_setr_epi8(
3944 0, 1, -1, 2, -2, 3, -3, 4,
3945 -4, 5, -5, i8::MAX, i8::MIN, 100, -100, -32,
3946 0, 1, -1, 2, -2, 3, -3, 4,
3947 -4, 5, -5, i8::MAX, i8::MIN, 100, -100, -32,
3948 );
3949 let r = _mm256_abs_epi8(a);
3950 #[rustfmt::skip]
3951 let e = _mm256_setr_epi8(
3952 0, 1, 1, 2, 2, 3, 3, 4,
3953 4, 5, 5, i8::MAX, i8::MAX.wrapping_add(1), 100, 100, 32,
3954 0, 1, 1, 2, 2, 3, 3, 4,
3955 4, 5, 5, i8::MAX, i8::MAX.wrapping_add(1), 100, 100, 32,
3956 );
3957 assert_eq_m256i(r, e);
3958 }
3959
3960 #[simd_test(enable = "avx2")]
3961 const fn test_mm256_add_epi64() {
3962 let a = _mm256_setr_epi64x(-10, 0, 100, 1_000_000_000);
3963 let b = _mm256_setr_epi64x(-1, 0, 1, 2);
3964 let r = _mm256_add_epi64(a, b);
3965 let e = _mm256_setr_epi64x(-11, 0, 101, 1_000_000_002);
3966 assert_eq_m256i(r, e);
3967 }
3968
3969 #[simd_test(enable = "avx2")]
3970 const fn test_mm256_add_epi32() {
3971 let a = _mm256_setr_epi32(-1, 0, 1, 2, 3, 4, 5, 6);
3972 let b = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8);
3973 let r = _mm256_add_epi32(a, b);
3974 let e = _mm256_setr_epi32(0, 2, 4, 6, 8, 10, 12, 14);
3975 assert_eq_m256i(r, e);
3976 }
3977
3978 #[simd_test(enable = "avx2")]
3979 const fn test_mm256_add_epi16() {
3980 #[rustfmt::skip]
3981 let a = _mm256_setr_epi16(
3982 0, 1, 2, 3, 4, 5, 6, 7,
3983 8, 9, 10, 11, 12, 13, 14, 15,
3984 );
3985 #[rustfmt::skip]
3986 let b = _mm256_setr_epi16(
3987 0, 1, 2, 3, 4, 5, 6, 7,
3988 8, 9, 10, 11, 12, 13, 14, 15,
3989 );
3990 let r = _mm256_add_epi16(a, b);
3991 #[rustfmt::skip]
3992 let e = _mm256_setr_epi16(
3993 0, 2, 4, 6, 8, 10, 12, 14,
3994 16, 18, 20, 22, 24, 26, 28, 30,
3995 );
3996 assert_eq_m256i(r, e);
3997 }
3998
3999 #[simd_test(enable = "avx2")]
4000 const fn test_mm256_add_epi8() {
4001 #[rustfmt::skip]
4002 let a = _mm256_setr_epi8(
4003 0, 1, 2, 3, 4, 5, 6, 7,
4004 8, 9, 10, 11, 12, 13, 14, 15,
4005 16, 17, 18, 19, 20, 21, 22, 23,
4006 24, 25, 26, 27, 28, 29, 30, 31,
4007 );
4008 #[rustfmt::skip]
4009 let b = _mm256_setr_epi8(
4010 0, 1, 2, 3, 4, 5, 6, 7,
4011 8, 9, 10, 11, 12, 13, 14, 15,
4012 16, 17, 18, 19, 20, 21, 22, 23,
4013 24, 25, 26, 27, 28, 29, 30, 31,
4014 );
4015 let r = _mm256_add_epi8(a, b);
4016 #[rustfmt::skip]
4017 let e = _mm256_setr_epi8(
4018 0, 2, 4, 6, 8, 10, 12, 14,
4019 16, 18, 20, 22, 24, 26, 28, 30,
4020 32, 34, 36, 38, 40, 42, 44, 46,
4021 48, 50, 52, 54, 56, 58, 60, 62,
4022 );
4023 assert_eq_m256i(r, e);
4024 }
4025
4026 #[simd_test(enable = "avx2")]
4027 const fn test_mm256_adds_epi8() {
4028 #[rustfmt::skip]
4029 let a = _mm256_setr_epi8(
4030 0, 1, 2, 3, 4, 5, 6, 7,
4031 8, 9, 10, 11, 12, 13, 14, 15,
4032 16, 17, 18, 19, 20, 21, 22, 23,
4033 24, 25, 26, 27, 28, 29, 30, 31,
4034 );
4035 #[rustfmt::skip]
4036 let b = _mm256_setr_epi8(
4037 32, 33, 34, 35, 36, 37, 38, 39,
4038 40, 41, 42, 43, 44, 45, 46, 47,
4039 48, 49, 50, 51, 52, 53, 54, 55,
4040 56, 57, 58, 59, 60, 61, 62, 63,
4041 );
4042 let r = _mm256_adds_epi8(a, b);
4043 #[rustfmt::skip]
4044 let e = _mm256_setr_epi8(
4045 32, 34, 36, 38, 40, 42, 44, 46,
4046 48, 50, 52, 54, 56, 58, 60, 62,
4047 64, 66, 68, 70, 72, 74, 76, 78,
4048 80, 82, 84, 86, 88, 90, 92, 94,
4049 );
4050 assert_eq_m256i(r, e);
4051 }
4052
4053 #[simd_test(enable = "avx2")]
4054 fn test_mm256_adds_epi8_saturate_positive() {
4055 let a = _mm256_set1_epi8(0x7F);
4056 let b = _mm256_set1_epi8(1);
4057 let r = _mm256_adds_epi8(a, b);
4058 assert_eq_m256i(r, a);
4059 }
4060
4061 #[simd_test(enable = "avx2")]
4062 fn test_mm256_adds_epi8_saturate_negative() {
4063 let a = _mm256_set1_epi8(-0x80);
4064 let b = _mm256_set1_epi8(-1);
4065 let r = _mm256_adds_epi8(a, b);
4066 assert_eq_m256i(r, a);
4067 }
4068
4069 #[simd_test(enable = "avx2")]
4070 const fn test_mm256_adds_epi16() {
4071 #[rustfmt::skip]
4072 let a = _mm256_setr_epi16(
4073 0, 1, 2, 3, 4, 5, 6, 7,
4074 8, 9, 10, 11, 12, 13, 14, 15,
4075 );
4076 #[rustfmt::skip]
4077 let b = _mm256_setr_epi16(
4078 32, 33, 34, 35, 36, 37, 38, 39,
4079 40, 41, 42, 43, 44, 45, 46, 47,
4080 );
4081 let r = _mm256_adds_epi16(a, b);
4082 #[rustfmt::skip]
4083 let e = _mm256_setr_epi16(
4084 32, 34, 36, 38, 40, 42, 44, 46,
4085 48, 50, 52, 54, 56, 58, 60, 62,
4086 );
4087
4088 assert_eq_m256i(r, e);
4089 }
4090
4091 #[simd_test(enable = "avx2")]
4092 fn test_mm256_adds_epi16_saturate_positive() {
4093 let a = _mm256_set1_epi16(0x7FFF);
4094 let b = _mm256_set1_epi16(1);
4095 let r = _mm256_adds_epi16(a, b);
4096 assert_eq_m256i(r, a);
4097 }
4098
4099 #[simd_test(enable = "avx2")]
4100 fn test_mm256_adds_epi16_saturate_negative() {
4101 let a = _mm256_set1_epi16(-0x8000);
4102 let b = _mm256_set1_epi16(-1);
4103 let r = _mm256_adds_epi16(a, b);
4104 assert_eq_m256i(r, a);
4105 }
4106
4107 #[simd_test(enable = "avx2")]
4108 const fn test_mm256_adds_epu8() {
4109 #[rustfmt::skip]
4110 let a = _mm256_setr_epi8(
4111 0, 1, 2, 3, 4, 5, 6, 7,
4112 8, 9, 10, 11, 12, 13, 14, 15,
4113 16, 17, 18, 19, 20, 21, 22, 23,
4114 24, 25, 26, 27, 28, 29, 30, 31,
4115 );
4116 #[rustfmt::skip]
4117 let b = _mm256_setr_epi8(
4118 32, 33, 34, 35, 36, 37, 38, 39,
4119 40, 41, 42, 43, 44, 45, 46, 47,
4120 48, 49, 50, 51, 52, 53, 54, 55,
4121 56, 57, 58, 59, 60, 61, 62, 63,
4122 );
4123 let r = _mm256_adds_epu8(a, b);
4124 #[rustfmt::skip]
4125 let e = _mm256_setr_epi8(
4126 32, 34, 36, 38, 40, 42, 44, 46,
4127 48, 50, 52, 54, 56, 58, 60, 62,
4128 64, 66, 68, 70, 72, 74, 76, 78,
4129 80, 82, 84, 86, 88, 90, 92, 94,
4130 );
4131 assert_eq_m256i(r, e);
4132 }
4133
4134 #[simd_test(enable = "avx2")]
4135 fn test_mm256_adds_epu8_saturate() {
4136 let a = _mm256_set1_epi8(!0);
4137 let b = _mm256_set1_epi8(1);
4138 let r = _mm256_adds_epu8(a, b);
4139 assert_eq_m256i(r, a);
4140 }
4141
4142 #[simd_test(enable = "avx2")]
4143 const fn test_mm256_adds_epu16() {
4144 #[rustfmt::skip]
4145 let a = _mm256_setr_epi16(
4146 0, 1, 2, 3, 4, 5, 6, 7,
4147 8, 9, 10, 11, 12, 13, 14, 15,
4148 );
4149 #[rustfmt::skip]
4150 let b = _mm256_setr_epi16(
4151 32, 33, 34, 35, 36, 37, 38, 39,
4152 40, 41, 42, 43, 44, 45, 46, 47,
4153 );
4154 let r = _mm256_adds_epu16(a, b);
4155 #[rustfmt::skip]
4156 let e = _mm256_setr_epi16(
4157 32, 34, 36, 38, 40, 42, 44, 46,
4158 48, 50, 52, 54, 56, 58, 60, 62,
4159 );
4160
4161 assert_eq_m256i(r, e);
4162 }
4163
4164 #[simd_test(enable = "avx2")]
4165 fn test_mm256_adds_epu16_saturate() {
4166 let a = _mm256_set1_epi16(!0);
4167 let b = _mm256_set1_epi16(1);
4168 let r = _mm256_adds_epu16(a, b);
4169 assert_eq_m256i(r, a);
4170 }
4171
4172 #[simd_test(enable = "avx2")]
4173 const fn test_mm256_and_si256() {
4174 let a = _mm256_set1_epi8(5);
4175 let b = _mm256_set1_epi8(3);
4176 let got = _mm256_and_si256(a, b);
4177 assert_eq_m256i(got, _mm256_set1_epi8(1));
4178 }
4179
4180 #[simd_test(enable = "avx2")]
4181 const fn test_mm256_andnot_si256() {
4182 let a = _mm256_set1_epi8(5);
4183 let b = _mm256_set1_epi8(3);
4184 let got = _mm256_andnot_si256(a, b);
4185 assert_eq_m256i(got, _mm256_set1_epi8(2));
4186 }
4187
4188 #[simd_test(enable = "avx2")]
4189 const fn test_mm256_avg_epu8() {
4190 let (a, b) = (_mm256_set1_epi8(3), _mm256_set1_epi8(9));
4191 let r = _mm256_avg_epu8(a, b);
4192 assert_eq_m256i(r, _mm256_set1_epi8(6));
4193 }
4194
4195 #[simd_test(enable = "avx2")]
4196 const fn test_mm256_avg_epu16() {
4197 let (a, b) = (_mm256_set1_epi16(3), _mm256_set1_epi16(9));
4198 let r = _mm256_avg_epu16(a, b);
4199 assert_eq_m256i(r, _mm256_set1_epi16(6));
4200 }
4201
4202 #[simd_test(enable = "avx2")]
4203 const fn test_mm_blend_epi32() {
4204 let (a, b) = (_mm_set1_epi32(3), _mm_set1_epi32(9));
4205 let e = _mm_setr_epi32(9, 3, 3, 3);
4206 let r = _mm_blend_epi32::<0x01>(a, b);
4207 assert_eq_m128i(r, e);
4208
4209 let r = _mm_blend_epi32::<0x0E>(b, a);
4210 assert_eq_m128i(r, e);
4211 }
4212
4213 #[simd_test(enable = "avx2")]
4214 const fn test_mm256_blend_epi32() {
4215 let (a, b) = (_mm256_set1_epi32(3), _mm256_set1_epi32(9));
4216 let e = _mm256_setr_epi32(9, 3, 3, 3, 3, 3, 3, 3);
4217 let r = _mm256_blend_epi32::<0x01>(a, b);
4218 assert_eq_m256i(r, e);
4219
4220 let e = _mm256_setr_epi32(3, 9, 3, 3, 3, 3, 3, 9);
4221 let r = _mm256_blend_epi32::<0x82>(a, b);
4222 assert_eq_m256i(r, e);
4223
4224 let e = _mm256_setr_epi32(3, 3, 9, 9, 9, 9, 9, 3);
4225 let r = _mm256_blend_epi32::<0x7C>(a, b);
4226 assert_eq_m256i(r, e);
4227 }
4228
4229 #[simd_test(enable = "avx2")]
4230 const fn test_mm256_blend_epi16() {
4231 let (a, b) = (_mm256_set1_epi16(3), _mm256_set1_epi16(9));
4232 let e = _mm256_setr_epi16(9, 3, 3, 3, 3, 3, 3, 3, 9, 3, 3, 3, 3, 3, 3, 3);
4233 let r = _mm256_blend_epi16::<0x01>(a, b);
4234 assert_eq_m256i(r, e);
4235
4236 let r = _mm256_blend_epi16::<0xFE>(b, a);
4237 assert_eq_m256i(r, e);
4238 }
4239
4240 #[simd_test(enable = "avx2")]
4241 const fn test_mm256_blendv_epi8() {
4242 let (a, b) = (_mm256_set1_epi8(4), _mm256_set1_epi8(2));
4243 let mask = _mm256_insert_epi8::<2>(_mm256_set1_epi8(0), -1);
4244 let e = _mm256_insert_epi8::<2>(_mm256_set1_epi8(4), 2);
4245 let r = _mm256_blendv_epi8(a, b, mask);
4246 assert_eq_m256i(r, e);
4247 }
4248
4249 #[simd_test(enable = "avx2")]
4250 const fn test_mm_broadcastb_epi8() {
4251 let a = _mm_insert_epi8::<0>(_mm_set1_epi8(0x00), 0x2a);
4252 let res = _mm_broadcastb_epi8(a);
4253 assert_eq_m128i(res, _mm_set1_epi8(0x2a));
4254 }
4255
4256 #[simd_test(enable = "avx2")]
4257 const fn test_mm256_broadcastb_epi8() {
4258 let a = _mm_insert_epi8::<0>(_mm_set1_epi8(0x00), 0x2a);
4259 let res = _mm256_broadcastb_epi8(a);
4260 assert_eq_m256i(res, _mm256_set1_epi8(0x2a));
4261 }
4262
4263 #[simd_test(enable = "avx2")]
4264 const fn test_mm_broadcastd_epi32() {
4265 let a = _mm_setr_epi32(0x2a, 0x8000000, 0, 0);
4266 let res = _mm_broadcastd_epi32(a);
4267 assert_eq_m128i(res, _mm_set1_epi32(0x2a));
4268 }
4269
4270 #[simd_test(enable = "avx2")]
4271 const fn test_mm256_broadcastd_epi32() {
4272 let a = _mm_setr_epi32(0x2a, 0x8000000, 0, 0);
4273 let res = _mm256_broadcastd_epi32(a);
4274 assert_eq_m256i(res, _mm256_set1_epi32(0x2a));
4275 }
4276
4277 #[simd_test(enable = "avx2")]
4278 const fn test_mm_broadcastq_epi64() {
4279 let a = _mm_setr_epi64x(0x1ffffffff, 0);
4280 let res = _mm_broadcastq_epi64(a);
4281 assert_eq_m128i(res, _mm_set1_epi64x(0x1ffffffff));
4282 }
4283
4284 #[simd_test(enable = "avx2")]
4285 const fn test_mm256_broadcastq_epi64() {
4286 let a = _mm_setr_epi64x(0x1ffffffff, 0);
4287 let res = _mm256_broadcastq_epi64(a);
4288 assert_eq_m256i(res, _mm256_set1_epi64x(0x1ffffffff));
4289 }
4290
4291 #[simd_test(enable = "avx2")]
4292 const fn test_mm_broadcastsd_pd() {
4293 let a = _mm_setr_pd(6.88, 3.44);
4294 let res = _mm_broadcastsd_pd(a);
4295 assert_eq_m128d(res, _mm_set1_pd(6.88));
4296 }
4297
4298 #[simd_test(enable = "avx2")]
4299 const fn test_mm256_broadcastsd_pd() {
4300 let a = _mm_setr_pd(6.88, 3.44);
4301 let res = _mm256_broadcastsd_pd(a);
4302 assert_eq_m256d(res, _mm256_set1_pd(6.88f64));
4303 }
4304
4305 #[simd_test(enable = "avx2")]
4306 const fn test_mm_broadcastsi128_si256() {
4307 let a = _mm_setr_epi64x(0x0987654321012334, 0x5678909876543210);
4308 let res = _mm_broadcastsi128_si256(a);
4309 let retval = _mm256_setr_epi64x(
4310 0x0987654321012334,
4311 0x5678909876543210,
4312 0x0987654321012334,
4313 0x5678909876543210,
4314 );
4315 assert_eq_m256i(res, retval);
4316 }
4317
4318 #[simd_test(enable = "avx2")]
4319 const fn test_mm256_broadcastsi128_si256() {
4320 let a = _mm_setr_epi64x(0x0987654321012334, 0x5678909876543210);
4321 let res = _mm256_broadcastsi128_si256(a);
4322 let retval = _mm256_setr_epi64x(
4323 0x0987654321012334,
4324 0x5678909876543210,
4325 0x0987654321012334,
4326 0x5678909876543210,
4327 );
4328 assert_eq_m256i(res, retval);
4329 }
4330
4331 #[simd_test(enable = "avx2")]
4332 const fn test_mm_broadcastss_ps() {
4333 let a = _mm_setr_ps(6.88, 3.44, 0.0, 0.0);
4334 let res = _mm_broadcastss_ps(a);
4335 assert_eq_m128(res, _mm_set1_ps(6.88));
4336 }
4337
4338 #[simd_test(enable = "avx2")]
4339 const fn test_mm256_broadcastss_ps() {
4340 let a = _mm_setr_ps(6.88, 3.44, 0.0, 0.0);
4341 let res = _mm256_broadcastss_ps(a);
4342 assert_eq_m256(res, _mm256_set1_ps(6.88));
4343 }
4344
4345 #[simd_test(enable = "avx2")]
4346 const fn test_mm_broadcastw_epi16() {
4347 let a = _mm_insert_epi16::<0>(_mm_set1_epi16(0x2a), 0x22b);
4348 let res = _mm_broadcastw_epi16(a);
4349 assert_eq_m128i(res, _mm_set1_epi16(0x22b));
4350 }
4351
4352 #[simd_test(enable = "avx2")]
4353 const fn test_mm256_broadcastw_epi16() {
4354 let a = _mm_insert_epi16::<0>(_mm_set1_epi16(0x2a), 0x22b);
4355 let res = _mm256_broadcastw_epi16(a);
4356 assert_eq_m256i(res, _mm256_set1_epi16(0x22b));
4357 }
4358
4359 #[simd_test(enable = "avx2")]
4360 const fn test_mm256_cmpeq_epi8() {
4361 #[rustfmt::skip]
4362 let a = _mm256_setr_epi8(
4363 0, 1, 2, 3, 4, 5, 6, 7,
4364 8, 9, 10, 11, 12, 13, 14, 15,
4365 16, 17, 18, 19, 20, 21, 22, 23,
4366 24, 25, 26, 27, 28, 29, 30, 31,
4367 );
4368 #[rustfmt::skip]
4369 let b = _mm256_setr_epi8(
4370 31, 30, 2, 28, 27, 26, 25, 24,
4371 23, 22, 21, 20, 19, 18, 17, 16,
4372 15, 14, 13, 12, 11, 10, 9, 8,
4373 7, 6, 5, 4, 3, 2, 1, 0,
4374 );
4375 let r = _mm256_cmpeq_epi8(a, b);
4376 assert_eq_m256i(r, _mm256_insert_epi8::<2>(_mm256_set1_epi8(0), !0));
4377 }
4378
4379 #[simd_test(enable = "avx2")]
4380 const fn test_mm256_cmpeq_epi16() {
4381 #[rustfmt::skip]
4382 let a = _mm256_setr_epi16(
4383 0, 1, 2, 3, 4, 5, 6, 7,
4384 8, 9, 10, 11, 12, 13, 14, 15,
4385 );
4386 #[rustfmt::skip]
4387 let b = _mm256_setr_epi16(
4388 15, 14, 2, 12, 11, 10, 9, 8,
4389 7, 6, 5, 4, 3, 2, 1, 0,
4390 );
4391 let r = _mm256_cmpeq_epi16(a, b);
4392 assert_eq_m256i(r, _mm256_insert_epi16::<2>(_mm256_set1_epi16(0), !0));
4393 }
4394
4395 #[simd_test(enable = "avx2")]
4396 const fn test_mm256_cmpeq_epi32() {
4397 let a = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
4398 let b = _mm256_setr_epi32(7, 6, 2, 4, 3, 2, 1, 0);
4399 let r = _mm256_cmpeq_epi32(a, b);
4400 let e = _mm256_set1_epi32(0);
4401 let e = _mm256_insert_epi32::<2>(e, !0);
4402 assert_eq_m256i(r, e);
4403 }
4404
4405 #[simd_test(enable = "avx2")]
4406 const fn test_mm256_cmpeq_epi64() {
4407 let a = _mm256_setr_epi64x(0, 1, 2, 3);
4408 let b = _mm256_setr_epi64x(3, 2, 2, 0);
4409 let r = _mm256_cmpeq_epi64(a, b);
4410 assert_eq_m256i(r, _mm256_insert_epi64::<2>(_mm256_set1_epi64x(0), !0));
4411 }
4412
4413 #[simd_test(enable = "avx2")]
4414 const fn test_mm256_cmpgt_epi8() {
4415 let a = _mm256_insert_epi8::<0>(_mm256_set1_epi8(0), 5);
4416 let b = _mm256_set1_epi8(0);
4417 let r = _mm256_cmpgt_epi8(a, b);
4418 assert_eq_m256i(r, _mm256_insert_epi8::<0>(_mm256_set1_epi8(0), !0));
4419 }
4420
4421 #[simd_test(enable = "avx2")]
4422 const fn test_mm256_cmpgt_epi16() {
4423 let a = _mm256_insert_epi16::<0>(_mm256_set1_epi16(0), 5);
4424 let b = _mm256_set1_epi16(0);
4425 let r = _mm256_cmpgt_epi16(a, b);
4426 assert_eq_m256i(r, _mm256_insert_epi16::<0>(_mm256_set1_epi16(0), !0));
4427 }
4428
4429 #[simd_test(enable = "avx2")]
4430 const fn test_mm256_cmpgt_epi32() {
4431 let a = _mm256_insert_epi32::<0>(_mm256_set1_epi32(0), 5);
4432 let b = _mm256_set1_epi32(0);
4433 let r = _mm256_cmpgt_epi32(a, b);
4434 assert_eq_m256i(r, _mm256_insert_epi32::<0>(_mm256_set1_epi32(0), !0));
4435 }
4436
4437 #[simd_test(enable = "avx2")]
4438 const fn test_mm256_cmpgt_epi64() {
4439 let a = _mm256_insert_epi64::<0>(_mm256_set1_epi64x(0), 5);
4440 let b = _mm256_set1_epi64x(0);
4441 let r = _mm256_cmpgt_epi64(a, b);
4442 assert_eq_m256i(r, _mm256_insert_epi64::<0>(_mm256_set1_epi64x(0), !0));
4443 }
4444
4445 #[simd_test(enable = "avx2")]
4446 const fn test_mm256_cvtepi8_epi16() {
4447 #[rustfmt::skip]
4448 let a = _mm_setr_epi8(
4449 0, 0, -1, 1, -2, 2, -3, 3,
4450 -4, 4, -5, 5, -6, 6, -7, 7,
4451 );
4452 #[rustfmt::skip]
4453 let r = _mm256_setr_epi16(
4454 0, 0, -1, 1, -2, 2, -3, 3,
4455 -4, 4, -5, 5, -6, 6, -7, 7,
4456 );
4457 assert_eq_m256i(r, _mm256_cvtepi8_epi16(a));
4458 }
4459
4460 #[simd_test(enable = "avx2")]
4461 const fn test_mm256_cvtepi8_epi32() {
4462 #[rustfmt::skip]
4463 let a = _mm_setr_epi8(
4464 0, 0, -1, 1, -2, 2, -3, 3,
4465 -4, 4, -5, 5, -6, 6, -7, 7,
4466 );
4467 let r = _mm256_setr_epi32(0, 0, -1, 1, -2, 2, -3, 3);
4468 assert_eq_m256i(r, _mm256_cvtepi8_epi32(a));
4469 }
4470
4471 #[simd_test(enable = "avx2")]
4472 const fn test_mm256_cvtepi8_epi64() {
4473 #[rustfmt::skip]
4474 let a = _mm_setr_epi8(
4475 0, 0, -1, 1, -2, 2, -3, 3,
4476 -4, 4, -5, 5, -6, 6, -7, 7,
4477 );
4478 let r = _mm256_setr_epi64x(0, 0, -1, 1);
4479 assert_eq_m256i(r, _mm256_cvtepi8_epi64(a));
4480 }
4481
4482 #[simd_test(enable = "avx2")]
4483 const fn test_mm256_cvtepi16_epi32() {
4484 let a = _mm_setr_epi16(0, 0, -1, 1, -2, 2, -3, 3);
4485 let r = _mm256_setr_epi32(0, 0, -1, 1, -2, 2, -3, 3);
4486 assert_eq_m256i(r, _mm256_cvtepi16_epi32(a));
4487 }
4488
4489 #[simd_test(enable = "avx2")]
4490 const fn test_mm256_cvtepi16_epi64() {
4491 let a = _mm_setr_epi16(0, 0, -1, 1, -2, 2, -3, 3);
4492 let r = _mm256_setr_epi64x(0, 0, -1, 1);
4493 assert_eq_m256i(r, _mm256_cvtepi16_epi64(a));
4494 }
4495
4496 #[simd_test(enable = "avx2")]
4497 const fn test_mm256_cvtepi32_epi64() {
4498 let a = _mm_setr_epi32(0, 0, -1, 1);
4499 let r = _mm256_setr_epi64x(0, 0, -1, 1);
4500 assert_eq_m256i(r, _mm256_cvtepi32_epi64(a));
4501 }
4502
4503 #[simd_test(enable = "avx2")]
4504 const fn test_mm256_cvtepu16_epi32() {
4505 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
4506 let r = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
4507 assert_eq_m256i(r, _mm256_cvtepu16_epi32(a));
4508 }
4509
4510 #[simd_test(enable = "avx2")]
4511 const fn test_mm256_cvtepu16_epi64() {
4512 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
4513 let r = _mm256_setr_epi64x(0, 1, 2, 3);
4514 assert_eq_m256i(r, _mm256_cvtepu16_epi64(a));
4515 }
4516
4517 #[simd_test(enable = "avx2")]
4518 const fn test_mm256_cvtepu32_epi64() {
4519 let a = _mm_setr_epi32(0, 1, 2, 3);
4520 let r = _mm256_setr_epi64x(0, 1, 2, 3);
4521 assert_eq_m256i(r, _mm256_cvtepu32_epi64(a));
4522 }
4523
4524 #[simd_test(enable = "avx2")]
4525 const fn test_mm256_cvtepu8_epi16() {
4526 #[rustfmt::skip]
4527 let a = _mm_setr_epi8(
4528 0, 1, 2, 3, 4, 5, 6, 7,
4529 8, 9, 10, 11, 12, 13, 14, 15,
4530 );
4531 #[rustfmt::skip]
4532 let r = _mm256_setr_epi16(
4533 0, 1, 2, 3, 4, 5, 6, 7,
4534 8, 9, 10, 11, 12, 13, 14, 15,
4535 );
4536 assert_eq_m256i(r, _mm256_cvtepu8_epi16(a));
4537 }
4538
4539 #[simd_test(enable = "avx2")]
4540 const fn test_mm256_cvtepu8_epi32() {
4541 #[rustfmt::skip]
4542 let a = _mm_setr_epi8(
4543 0, 1, 2, 3, 4, 5, 6, 7,
4544 8, 9, 10, 11, 12, 13, 14, 15,
4545 );
4546 let r = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
4547 assert_eq_m256i(r, _mm256_cvtepu8_epi32(a));
4548 }
4549
4550 #[simd_test(enable = "avx2")]
4551 const fn test_mm256_cvtepu8_epi64() {
4552 #[rustfmt::skip]
4553 let a = _mm_setr_epi8(
4554 0, 1, 2, 3, 4, 5, 6, 7,
4555 8, 9, 10, 11, 12, 13, 14, 15,
4556 );
4557 let r = _mm256_setr_epi64x(0, 1, 2, 3);
4558 assert_eq_m256i(r, _mm256_cvtepu8_epi64(a));
4559 }
4560
4561 #[simd_test(enable = "avx2")]
4562 const fn test_mm256_extracti128_si256() {
4563 let a = _mm256_setr_epi64x(1, 2, 3, 4);
4564 let r = _mm256_extracti128_si256::<1>(a);
4565 let e = _mm_setr_epi64x(3, 4);
4566 assert_eq_m128i(r, e);
4567 }
4568
4569 #[simd_test(enable = "avx2")]
4570 const fn test_mm256_hadd_epi16() {
4571 let a = _mm256_set1_epi16(2);
4572 let b = _mm256_set1_epi16(4);
4573 let r = _mm256_hadd_epi16(a, b);
4574 let e = _mm256_setr_epi16(4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8);
4575 assert_eq_m256i(r, e);
4576 }
4577
4578 #[simd_test(enable = "avx2")]
4579 const fn test_mm256_hadd_epi32() {
4580 let a = _mm256_set1_epi32(2);
4581 let b = _mm256_set1_epi32(4);
4582 let r = _mm256_hadd_epi32(a, b);
4583 let e = _mm256_setr_epi32(4, 4, 8, 8, 4, 4, 8, 8);
4584 assert_eq_m256i(r, e);
4585 }
4586
4587 #[simd_test(enable = "avx2")]
4588 fn test_mm256_hadds_epi16() {
4589 let a = _mm256_set1_epi16(2);
4590 let a = _mm256_insert_epi16::<0>(a, 0x7fff);
4591 let a = _mm256_insert_epi16::<1>(a, 1);
4592 let b = _mm256_set1_epi16(4);
4593 let r = _mm256_hadds_epi16(a, b);
4594 #[rustfmt::skip]
4595 let e = _mm256_setr_epi16(
4596 0x7FFF, 4, 4, 4, 8, 8, 8, 8,
4597 4, 4, 4, 4, 8, 8, 8, 8,
4598 );
4599 assert_eq_m256i(r, e);
4600 }
4601
4602 #[simd_test(enable = "avx2")]
4603 const fn test_mm256_hsub_epi16() {
4604 let a = _mm256_set1_epi16(2);
4605 let b = _mm256_set1_epi16(4);
4606 let r = _mm256_hsub_epi16(a, b);
4607 let e = _mm256_set1_epi16(0);
4608 assert_eq_m256i(r, e);
4609 }
4610
4611 #[simd_test(enable = "avx2")]
4612 const fn test_mm256_hsub_epi32() {
4613 let a = _mm256_set1_epi32(2);
4614 let b = _mm256_set1_epi32(4);
4615 let r = _mm256_hsub_epi32(a, b);
4616 let e = _mm256_set1_epi32(0);
4617 assert_eq_m256i(r, e);
4618 }
4619
4620 #[simd_test(enable = "avx2")]
4621 fn test_mm256_hsubs_epi16() {
4622 let a = _mm256_set1_epi16(2);
4623 let a = _mm256_insert_epi16::<0>(a, 0x7fff);
4624 let a = _mm256_insert_epi16::<1>(a, -1);
4625 let b = _mm256_set1_epi16(4);
4626 let r = _mm256_hsubs_epi16(a, b);
4627 let e = _mm256_insert_epi16::<0>(_mm256_set1_epi16(0), 0x7FFF);
4628 assert_eq_m256i(r, e);
4629 }
4630
4631 #[simd_test(enable = "avx2")]
4632 fn test_mm256_madd_epi16() {
4633 let a = _mm256_set1_epi16(2);
4634 let b = _mm256_set1_epi16(4);
4635 let r = _mm256_madd_epi16(a, b);
4636 let e = _mm256_set1_epi32(16);
4637 assert_eq_m256i(r, e);
4638 }
4639
4640 #[target_feature(enable = "avx2")]
4641 #[cfg_attr(test, assert_instr(vpmaddwd))]
4642 unsafe fn test_mm256_madd_epi16_mul_one(v: __m256i) -> __m256i {
4643 let one_v = _mm256_set1_epi16(1);
4647 _mm256_madd_epi16(v, one_v)
4648 }
4649
4650 #[target_feature(enable = "avx2")]
4651 #[cfg_attr(test, assert_instr(vpmaddwd))]
4652 unsafe fn test_mm256_madd_epi16_shl(v: __m256i) -> __m256i {
4653 let shift_value = _mm256_set1_epi32(12i32);
4657 _mm256_madd_epi16(v, shift_value)
4658 }
4659
4660 #[simd_test(enable = "avx2")]
4661 const fn test_mm256_inserti128_si256() {
4662 let a = _mm256_setr_epi64x(1, 2, 3, 4);
4663 let b = _mm_setr_epi64x(7, 8);
4664 let r = _mm256_inserti128_si256::<1>(a, b);
4665 let e = _mm256_setr_epi64x(1, 2, 7, 8);
4666 assert_eq_m256i(r, e);
4667 }
4668
4669 #[simd_test(enable = "avx2")]
4670 fn test_mm256_maddubs_epi16() {
4671 let a = _mm256_set1_epi8(2);
4672 let b = _mm256_set1_epi8(4);
4673 let r = _mm256_maddubs_epi16(a, b);
4674 let e = _mm256_set1_epi16(16);
4675 assert_eq_m256i(r, e);
4676 }
4677
4678 #[simd_test(enable = "avx2")]
4679 const fn test_mm_maskload_epi32() {
4680 let nums = [1, 2, 3, 4];
4681 let a = &nums as *const i32;
4682 let mask = _mm_setr_epi32(-1, 0, 0, -1);
4683 let r = unsafe { _mm_maskload_epi32(a, mask) };
4684 let e = _mm_setr_epi32(1, 0, 0, 4);
4685 assert_eq_m128i(r, e);
4686 }
4687
4688 #[simd_test(enable = "avx2")]
4689 const fn test_mm256_maskload_epi32() {
4690 let nums = [1, 2, 3, 4, 5, 6, 7, 8];
4691 let a = &nums as *const i32;
4692 let mask = _mm256_setr_epi32(-1, 0, 0, -1, 0, -1, -1, 0);
4693 let r = unsafe { _mm256_maskload_epi32(a, mask) };
4694 let e = _mm256_setr_epi32(1, 0, 0, 4, 0, 6, 7, 0);
4695 assert_eq_m256i(r, e);
4696 }
4697
4698 #[simd_test(enable = "avx2")]
4699 const fn test_mm_maskload_epi64() {
4700 let nums = [1_i64, 2_i64];
4701 let a = &nums as *const i64;
4702 let mask = _mm_setr_epi64x(0, -1);
4703 let r = unsafe { _mm_maskload_epi64(a, mask) };
4704 let e = _mm_setr_epi64x(0, 2);
4705 assert_eq_m128i(r, e);
4706 }
4707
4708 #[simd_test(enable = "avx2")]
4709 const fn test_mm256_maskload_epi64() {
4710 let nums = [1_i64, 2_i64, 3_i64, 4_i64];
4711 let a = &nums as *const i64;
4712 let mask = _mm256_setr_epi64x(0, -1, -1, 0);
4713 let r = unsafe { _mm256_maskload_epi64(a, mask) };
4714 let e = _mm256_setr_epi64x(0, 2, 3, 0);
4715 assert_eq_m256i(r, e);
4716 }
4717
4718 #[simd_test(enable = "avx2")]
4719 const fn test_mm_maskstore_epi32() {
4720 let a = _mm_setr_epi32(1, 2, 3, 4);
4721 let mut arr = [-1, -1, -1, -1];
4722 let mask = _mm_setr_epi32(-1, 0, 0, -1);
4723 unsafe {
4724 _mm_maskstore_epi32(arr.as_mut_ptr(), mask, a);
4725 }
4726 let e = [1, -1, -1, 4];
4727 assert_eq!(arr, e);
4728 }
4729
4730 #[simd_test(enable = "avx2")]
4731 const fn test_mm256_maskstore_epi32() {
4732 let a = _mm256_setr_epi32(1, 0x6d726f, 3, 42, 0x777161, 6, 7, 8);
4733 let mut arr = [-1, -1, -1, 0x776173, -1, 0x68657265, -1, -1];
4734 let mask = _mm256_setr_epi32(-1, 0, 0, -1, 0, -1, -1, 0);
4735 unsafe {
4736 _mm256_maskstore_epi32(arr.as_mut_ptr(), mask, a);
4737 }
4738 let e = [1, -1, -1, 42, -1, 6, 7, -1];
4739 assert_eq!(arr, e);
4740 }
4741
4742 #[simd_test(enable = "avx2")]
4743 const fn test_mm_maskstore_epi64() {
4744 let a = _mm_setr_epi64x(1_i64, 2_i64);
4745 let mut arr = [-1_i64, -1_i64];
4746 let mask = _mm_setr_epi64x(0, -1);
4747 unsafe {
4748 _mm_maskstore_epi64(arr.as_mut_ptr(), mask, a);
4749 }
4750 let e = [-1, 2];
4751 assert_eq!(arr, e);
4752 }
4753
4754 #[simd_test(enable = "avx2")]
4755 const fn test_mm256_maskstore_epi64() {
4756 let a = _mm256_setr_epi64x(1_i64, 2_i64, 3_i64, 4_i64);
4757 let mut arr = [-1_i64, -1_i64, -1_i64, -1_i64];
4758 let mask = _mm256_setr_epi64x(0, -1, -1, 0);
4759 unsafe {
4760 _mm256_maskstore_epi64(arr.as_mut_ptr(), mask, a);
4761 }
4762 let e = [-1, 2, 3, -1];
4763 assert_eq!(arr, e);
4764 }
4765
4766 #[simd_test(enable = "avx2")]
4767 const fn test_mm256_max_epi16() {
4768 let a = _mm256_set1_epi16(2);
4769 let b = _mm256_set1_epi16(4);
4770 let r = _mm256_max_epi16(a, b);
4771 assert_eq_m256i(r, b);
4772 }
4773
4774 #[simd_test(enable = "avx2")]
4775 const fn test_mm256_max_epi32() {
4776 let a = _mm256_set1_epi32(2);
4777 let b = _mm256_set1_epi32(4);
4778 let r = _mm256_max_epi32(a, b);
4779 assert_eq_m256i(r, b);
4780 }
4781
4782 #[simd_test(enable = "avx2")]
4783 const fn test_mm256_max_epi8() {
4784 let a = _mm256_set1_epi8(2);
4785 let b = _mm256_set1_epi8(4);
4786 let r = _mm256_max_epi8(a, b);
4787 assert_eq_m256i(r, b);
4788 }
4789
4790 #[simd_test(enable = "avx2")]
4791 const fn test_mm256_max_epu16() {
4792 let a = _mm256_set1_epi16(2);
4793 let b = _mm256_set1_epi16(4);
4794 let r = _mm256_max_epu16(a, b);
4795 assert_eq_m256i(r, b);
4796 }
4797
4798 #[simd_test(enable = "avx2")]
4799 const fn test_mm256_max_epu32() {
4800 let a = _mm256_set1_epi32(2);
4801 let b = _mm256_set1_epi32(4);
4802 let r = _mm256_max_epu32(a, b);
4803 assert_eq_m256i(r, b);
4804 }
4805
4806 #[simd_test(enable = "avx2")]
4807 const fn test_mm256_max_epu8() {
4808 let a = _mm256_set1_epi8(2);
4809 let b = _mm256_set1_epi8(4);
4810 let r = _mm256_max_epu8(a, b);
4811 assert_eq_m256i(r, b);
4812 }
4813
4814 #[simd_test(enable = "avx2")]
4815 const fn test_mm256_min_epi16() {
4816 let a = _mm256_set1_epi16(2);
4817 let b = _mm256_set1_epi16(4);
4818 let r = _mm256_min_epi16(a, b);
4819 assert_eq_m256i(r, a);
4820 }
4821
4822 #[simd_test(enable = "avx2")]
4823 const fn test_mm256_min_epi32() {
4824 let a = _mm256_set1_epi32(2);
4825 let b = _mm256_set1_epi32(4);
4826 let r = _mm256_min_epi32(a, b);
4827 assert_eq_m256i(r, a);
4828 }
4829
4830 #[simd_test(enable = "avx2")]
4831 const fn test_mm256_min_epi8() {
4832 let a = _mm256_set1_epi8(2);
4833 let b = _mm256_set1_epi8(4);
4834 let r = _mm256_min_epi8(a, b);
4835 assert_eq_m256i(r, a);
4836 }
4837
4838 #[simd_test(enable = "avx2")]
4839 const fn test_mm256_min_epu16() {
4840 let a = _mm256_set1_epi16(2);
4841 let b = _mm256_set1_epi16(4);
4842 let r = _mm256_min_epu16(a, b);
4843 assert_eq_m256i(r, a);
4844 }
4845
4846 #[simd_test(enable = "avx2")]
4847 const fn test_mm256_min_epu32() {
4848 let a = _mm256_set1_epi32(2);
4849 let b = _mm256_set1_epi32(4);
4850 let r = _mm256_min_epu32(a, b);
4851 assert_eq_m256i(r, a);
4852 }
4853
4854 #[simd_test(enable = "avx2")]
4855 const fn test_mm256_min_epu8() {
4856 let a = _mm256_set1_epi8(2);
4857 let b = _mm256_set1_epi8(4);
4858 let r = _mm256_min_epu8(a, b);
4859 assert_eq_m256i(r, a);
4860 }
4861
4862 #[simd_test(enable = "avx2")]
4863 const fn test_mm256_movemask_epi8() {
4864 let a = _mm256_set1_epi8(-1);
4865 let r = _mm256_movemask_epi8(a);
4866 let e = -1;
4867 assert_eq!(r, e);
4868 }
4869
4870 #[simd_test(enable = "avx2")]
4871 fn test_mm256_mpsadbw_epu8() {
4872 let a = _mm256_set1_epi8(2);
4873 let b = _mm256_set1_epi8(4);
4874 let r = _mm256_mpsadbw_epu8::<0>(a, b);
4875 let e = _mm256_set1_epi16(8);
4876 assert_eq_m256i(r, e);
4877 }
4878
4879 #[simd_test(enable = "avx2")]
4880 const fn test_mm256_mul_epi32() {
4881 let a = _mm256_setr_epi32(0, 0, 0, 0, 2, 2, 2, 2);
4882 let b = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8);
4883 let r = _mm256_mul_epi32(a, b);
4884 let e = _mm256_setr_epi64x(0, 0, 10, 14);
4885 assert_eq_m256i(r, e);
4886 }
4887
4888 #[simd_test(enable = "avx2")]
4889 const fn test_mm256_mul_epu32() {
4890 let a = _mm256_setr_epi32(0, 0, 0, 0, 2, 2, 2, 2);
4891 let b = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8);
4892 let r = _mm256_mul_epu32(a, b);
4893 let e = _mm256_setr_epi64x(0, 0, 10, 14);
4894 assert_eq_m256i(r, e);
4895 }
4896
4897 #[simd_test(enable = "avx2")]
4898 const fn test_mm256_mulhi_epi16() {
4899 let a = _mm256_set1_epi16(6535);
4900 let b = _mm256_set1_epi16(6535);
4901 let r = _mm256_mulhi_epi16(a, b);
4902 let e = _mm256_set1_epi16(651);
4903 assert_eq_m256i(r, e);
4904 }
4905
4906 #[simd_test(enable = "avx2")]
4907 const fn test_mm256_mulhi_epu16() {
4908 let a = _mm256_set1_epi16(6535);
4909 let b = _mm256_set1_epi16(6535);
4910 let r = _mm256_mulhi_epu16(a, b);
4911 let e = _mm256_set1_epi16(651);
4912 assert_eq_m256i(r, e);
4913 }
4914
4915 #[simd_test(enable = "avx2")]
4916 const fn test_mm256_mullo_epi16() {
4917 let a = _mm256_set1_epi16(2);
4918 let b = _mm256_set1_epi16(4);
4919 let r = _mm256_mullo_epi16(a, b);
4920 let e = _mm256_set1_epi16(8);
4921 assert_eq_m256i(r, e);
4922 }
4923
4924 #[simd_test(enable = "avx2")]
4925 const fn test_mm256_mullo_epi32() {
4926 let a = _mm256_set1_epi32(2);
4927 let b = _mm256_set1_epi32(4);
4928 let r = _mm256_mullo_epi32(a, b);
4929 let e = _mm256_set1_epi32(8);
4930 assert_eq_m256i(r, e);
4931 }
4932
4933 #[simd_test(enable = "avx2")]
4934 fn test_mm256_mulhrs_epi16() {
4935 let a = _mm256_set1_epi16(2);
4936 let b = _mm256_set1_epi16(4);
4937 let r = _mm256_mullo_epi16(a, b);
4938 let e = _mm256_set1_epi16(8);
4939 assert_eq_m256i(r, e);
4940 }
4941
4942 #[simd_test(enable = "avx2")]
4943 const fn test_mm256_or_si256() {
4944 let a = _mm256_set1_epi8(-1);
4945 let b = _mm256_set1_epi8(0);
4946 let r = _mm256_or_si256(a, b);
4947 assert_eq_m256i(r, a);
4948 }
4949
4950 #[simd_test(enable = "avx2")]
4951 fn test_mm256_packs_epi16() {
4952 let a = _mm256_set1_epi16(2);
4953 let b = _mm256_set1_epi16(4);
4954 let r = _mm256_packs_epi16(a, b);
4955 #[rustfmt::skip]
4956 let e = _mm256_setr_epi8(
4957 2, 2, 2, 2, 2, 2, 2, 2,
4958 4, 4, 4, 4, 4, 4, 4, 4,
4959 2, 2, 2, 2, 2, 2, 2, 2,
4960 4, 4, 4, 4, 4, 4, 4, 4,
4961 );
4962
4963 assert_eq_m256i(r, e);
4964 }
4965
4966 #[simd_test(enable = "avx2")]
4967 fn test_mm256_packs_epi32() {
4968 let a = _mm256_set1_epi32(2);
4969 let b = _mm256_set1_epi32(4);
4970 let r = _mm256_packs_epi32(a, b);
4971 let e = _mm256_setr_epi16(2, 2, 2, 2, 4, 4, 4, 4, 2, 2, 2, 2, 4, 4, 4, 4);
4972
4973 assert_eq_m256i(r, e);
4974 }
4975
4976 #[simd_test(enable = "avx2")]
4977 fn test_mm256_packus_epi16() {
4978 let a = _mm256_set1_epi16(2);
4979 let b = _mm256_set1_epi16(4);
4980 let r = _mm256_packus_epi16(a, b);
4981 #[rustfmt::skip]
4982 let e = _mm256_setr_epi8(
4983 2, 2, 2, 2, 2, 2, 2, 2,
4984 4, 4, 4, 4, 4, 4, 4, 4,
4985 2, 2, 2, 2, 2, 2, 2, 2,
4986 4, 4, 4, 4, 4, 4, 4, 4,
4987 );
4988
4989 assert_eq_m256i(r, e);
4990 }
4991
4992 #[simd_test(enable = "avx2")]
4993 fn test_mm256_packus_epi32() {
4994 let a = _mm256_set1_epi32(2);
4995 let b = _mm256_set1_epi32(4);
4996 let r = _mm256_packus_epi32(a, b);
4997 let e = _mm256_setr_epi16(2, 2, 2, 2, 4, 4, 4, 4, 2, 2, 2, 2, 4, 4, 4, 4);
4998
4999 assert_eq_m256i(r, e);
5000 }
5001
5002 #[simd_test(enable = "avx2")]
5003 fn test_mm256_sad_epu8() {
5004 let a = _mm256_set1_epi8(2);
5005 let b = _mm256_set1_epi8(4);
5006 let r = _mm256_sad_epu8(a, b);
5007 let e = _mm256_set1_epi64x(16);
5008 assert_eq_m256i(r, e);
5009 }
5010
5011 #[simd_test(enable = "avx2")]
5012 const fn test_mm256_shufflehi_epi16() {
5013 #[rustfmt::skip]
5014 let a = _mm256_setr_epi16(
5015 0, 1, 2, 3, 11, 22, 33, 44,
5016 4, 5, 6, 7, 55, 66, 77, 88,
5017 );
5018 #[rustfmt::skip]
5019 let e = _mm256_setr_epi16(
5020 0, 1, 2, 3, 44, 22, 22, 11,
5021 4, 5, 6, 7, 88, 66, 66, 55,
5022 );
5023 let r = _mm256_shufflehi_epi16::<0b00_01_01_11>(a);
5024 assert_eq_m256i(r, e);
5025 }
5026
5027 #[simd_test(enable = "avx2")]
5028 const fn test_mm256_shufflelo_epi16() {
5029 #[rustfmt::skip]
5030 let a = _mm256_setr_epi16(
5031 11, 22, 33, 44, 0, 1, 2, 3,
5032 55, 66, 77, 88, 4, 5, 6, 7,
5033 );
5034 #[rustfmt::skip]
5035 let e = _mm256_setr_epi16(
5036 44, 22, 22, 11, 0, 1, 2, 3,
5037 88, 66, 66, 55, 4, 5, 6, 7,
5038 );
5039 let r = _mm256_shufflelo_epi16::<0b00_01_01_11>(a);
5040 assert_eq_m256i(r, e);
5041 }
5042
5043 #[simd_test(enable = "avx2")]
5044 fn test_mm256_sign_epi16() {
5045 let a = _mm256_set1_epi16(2);
5046 let b = _mm256_set1_epi16(-1);
5047 let r = _mm256_sign_epi16(a, b);
5048 let e = _mm256_set1_epi16(-2);
5049 assert_eq_m256i(r, e);
5050 }
5051
5052 #[simd_test(enable = "avx2")]
5053 fn test_mm256_sign_epi32() {
5054 let a = _mm256_set1_epi32(2);
5055 let b = _mm256_set1_epi32(-1);
5056 let r = _mm256_sign_epi32(a, b);
5057 let e = _mm256_set1_epi32(-2);
5058 assert_eq_m256i(r, e);
5059 }
5060
5061 #[simd_test(enable = "avx2")]
5062 fn test_mm256_sign_epi8() {
5063 let a = _mm256_set1_epi8(2);
5064 let b = _mm256_set1_epi8(-1);
5065 let r = _mm256_sign_epi8(a, b);
5066 let e = _mm256_set1_epi8(-2);
5067 assert_eq_m256i(r, e);
5068 }
5069
5070 #[simd_test(enable = "avx2")]
5071 fn test_mm256_sll_epi16() {
5072 let a = _mm256_set1_epi16(0xFF);
5073 let b = _mm_insert_epi16::<0>(_mm_set1_epi16(0), 4);
5074 let r = _mm256_sll_epi16(a, b);
5075 assert_eq_m256i(r, _mm256_set1_epi16(0xFF0));
5076 }
5077
5078 #[simd_test(enable = "avx2")]
5079 fn test_mm256_sll_epi32() {
5080 let a = _mm256_set1_epi32(0xFFFF);
5081 let b = _mm_insert_epi32::<0>(_mm_set1_epi32(0), 4);
5082 let r = _mm256_sll_epi32(a, b);
5083 assert_eq_m256i(r, _mm256_set1_epi32(0xFFFF0));
5084 }
5085
5086 #[simd_test(enable = "avx2")]
5087 fn test_mm256_sll_epi64() {
5088 let a = _mm256_set1_epi64x(0xFFFFFFFF);
5089 let b = _mm_insert_epi64::<0>(_mm_set1_epi64x(0), 4);
5090 let r = _mm256_sll_epi64(a, b);
5091 assert_eq_m256i(r, _mm256_set1_epi64x(0xFFFFFFFF0));
5092 }
5093
5094 #[simd_test(enable = "avx2")]
5095 const fn test_mm256_slli_epi16() {
5096 assert_eq_m256i(
5097 _mm256_slli_epi16::<4>(_mm256_set1_epi16(0xFF)),
5098 _mm256_set1_epi16(0xFF0),
5099 );
5100 }
5101
5102 #[simd_test(enable = "avx2")]
5103 const fn test_mm256_slli_epi32() {
5104 assert_eq_m256i(
5105 _mm256_slli_epi32::<4>(_mm256_set1_epi32(0xFFFF)),
5106 _mm256_set1_epi32(0xFFFF0),
5107 );
5108 }
5109
5110 #[simd_test(enable = "avx2")]
5111 const fn test_mm256_slli_epi64() {
5112 assert_eq_m256i(
5113 _mm256_slli_epi64::<4>(_mm256_set1_epi64x(0xFFFFFFFF)),
5114 _mm256_set1_epi64x(0xFFFFFFFF0),
5115 );
5116 }
5117
5118 #[simd_test(enable = "avx2")]
5119 const fn test_mm256_slli_si256() {
5120 let a = _mm256_set1_epi64x(0xFFFFFFFF);
5121 let r = _mm256_slli_si256::<3>(a);
5122 assert_eq_m256i(r, _mm256_set1_epi64x(0xFFFFFFFF000000));
5123 }
5124
5125 #[simd_test(enable = "avx2")]
5126 fn test_mm_sllv_epi32() {
5127 let a = _mm_set1_epi32(2);
5128 let b = _mm_set1_epi32(1);
5129 let r = _mm_sllv_epi32(a, b);
5130 let e = _mm_set1_epi32(4);
5131 assert_eq_m128i(r, e);
5132 }
5133
5134 #[simd_test(enable = "avx2")]
5135 fn test_mm256_sllv_epi32() {
5136 let a = _mm256_set1_epi32(2);
5137 let b = _mm256_set1_epi32(1);
5138 let r = _mm256_sllv_epi32(a, b);
5139 let e = _mm256_set1_epi32(4);
5140 assert_eq_m256i(r, e);
5141 }
5142
5143 #[simd_test(enable = "avx2")]
5144 fn test_mm_sllv_epi64() {
5145 let a = _mm_set_epi64x(2, 3);
5146 let b = _mm_set_epi64x(1, 2);
5147 let r = _mm_sllv_epi64(a, b);
5148 let e = _mm_set_epi64x(2i64.unbounded_shl(1), 3i64.unbounded_shl(2));
5150 assert_eq_m128i(r, e);
5151 let e = _mm_set_epi64x(4, 12);
5153 assert_eq_m128i(r, e);
5154
5155 let a = _mm_set_epi64x(1, 2);
5158 let b = _mm_set_epi64x(64, 65);
5159 let r = _mm_sllv_epi64(a, b);
5160 let e = _mm_set_epi64x(1i64.unbounded_shl(64), 2i64.unbounded_shl(65));
5161 assert_eq_m128i(r, e);
5162 let e = _mm_set_epi64x(0, 0);
5163 assert_eq_m128i(r, e);
5164 }
5165
5166 #[simd_test(enable = "avx2")]
5167 fn test_mm256_sllv_epi64() {
5168 let a = _mm256_set1_epi64x(2);
5169 let b = _mm256_set1_epi64x(1);
5170 let r = _mm256_sllv_epi64(a, b);
5171 let e = _mm256_set1_epi64x(4);
5172 assert_eq_m256i(r, e);
5173 }
5174
5175 #[simd_test(enable = "avx2")]
5176 fn test_mm256_sra_epi16() {
5177 let a = _mm256_set1_epi16(-1);
5178 let b = _mm_setr_epi16(1, 0, 0, 0, 0, 0, 0, 0);
5179 let r = _mm256_sra_epi16(a, b);
5180 assert_eq_m256i(r, _mm256_set1_epi16(-1));
5181 }
5182
5183 #[simd_test(enable = "avx2")]
5184 fn test_mm256_sra_epi32() {
5185 let a = _mm256_set1_epi32(-1);
5186 let b = _mm_insert_epi32::<0>(_mm_set1_epi32(0), 1);
5187 let r = _mm256_sra_epi32(a, b);
5188 assert_eq_m256i(r, _mm256_set1_epi32(-1));
5189 }
5190
5191 #[simd_test(enable = "avx2")]
5192 const fn test_mm256_srai_epi16() {
5193 assert_eq_m256i(
5194 _mm256_srai_epi16::<1>(_mm256_set1_epi16(-1)),
5195 _mm256_set1_epi16(-1),
5196 );
5197 }
5198
5199 #[simd_test(enable = "avx2")]
5200 const fn test_mm256_srai_epi32() {
5201 assert_eq_m256i(
5202 _mm256_srai_epi32::<1>(_mm256_set1_epi32(-1)),
5203 _mm256_set1_epi32(-1),
5204 );
5205 }
5206
5207 #[simd_test(enable = "avx2")]
5208 fn test_mm_srav_epi32() {
5209 let a = _mm_set_epi32(16, -32, 64, -128);
5210 let b = _mm_set_epi32(4, 3, 2, 1);
5211 let r = _mm_srav_epi32(a, b);
5212 let e = _mm_set_epi32(1, -4, 16, -64);
5213 assert_eq_m128i(r, e);
5214
5215 let a = _mm_set_epi32(-16, -32, -64, -128);
5218 let b = _mm_set_epi32(31, 32, 33, 0);
5219 let r = _mm_srav_epi32(a, b);
5220 let e = _mm_set_epi32(
5222 (-16i32).unbounded_shr(31),
5223 (-32i32).unbounded_shr(32),
5224 (-64i32).unbounded_shr(33),
5225 (-128i32).unbounded_shr(0),
5226 );
5227 assert_eq_m128i(r, e);
5228 let e = _mm_set_epi32(-1, -1, -1, -128);
5230 assert_eq_m128i(r, e);
5231 }
5232
5233 #[simd_test(enable = "avx2")]
5234 fn test_mm256_srav_epi32() {
5235 let a = _mm256_set1_epi32(4);
5236 let count = _mm256_set1_epi32(1);
5237 let r = _mm256_srav_epi32(a, count);
5238 let e = _mm256_set1_epi32(2);
5239 assert_eq_m256i(r, e);
5240 }
5241
5242 #[simd_test(enable = "avx2")]
5243 const fn test_mm256_srli_si256() {
5244 #[rustfmt::skip]
5245 let a = _mm256_setr_epi8(
5246 1, 2, 3, 4, 5, 6, 7, 8,
5247 9, 10, 11, 12, 13, 14, 15, 16,
5248 17, 18, 19, 20, 21, 22, 23, 24,
5249 25, 26, 27, 28, 29, 30, 31, 32,
5250 );
5251 let r = _mm256_srli_si256::<3>(a);
5252 #[rustfmt::skip]
5253 let e = _mm256_setr_epi8(
5254 4, 5, 6, 7, 8, 9, 10, 11,
5255 12, 13, 14, 15, 16, 0, 0, 0,
5256 20, 21, 22, 23, 24, 25, 26, 27,
5257 28, 29, 30, 31, 32, 0, 0, 0,
5258 );
5259 assert_eq_m256i(r, e);
5260 }
5261
5262 #[simd_test(enable = "avx2")]
5263 fn test_mm256_srl_epi16() {
5264 let a = _mm256_set1_epi16(0xFF);
5265 let b = _mm_insert_epi16::<0>(_mm_set1_epi16(0), 4);
5266 let r = _mm256_srl_epi16(a, b);
5267 assert_eq_m256i(r, _mm256_set1_epi16(0xF));
5268 }
5269
5270 #[simd_test(enable = "avx2")]
5271 fn test_mm256_srl_epi32() {
5272 let a = _mm256_set1_epi32(0xFFFF);
5273 let b = _mm_insert_epi32::<0>(_mm_set1_epi32(0), 4);
5274 let r = _mm256_srl_epi32(a, b);
5275 assert_eq_m256i(r, _mm256_set1_epi32(0xFFF));
5276 }
5277
5278 #[simd_test(enable = "avx2")]
5279 fn test_mm256_srl_epi64() {
5280 let a = _mm256_set1_epi64x(0xFFFFFFFF);
5281 let b = _mm_setr_epi64x(4, 0);
5282 let r = _mm256_srl_epi64(a, b);
5283 assert_eq_m256i(r, _mm256_set1_epi64x(0xFFFFFFF));
5284 }
5285
5286 #[simd_test(enable = "avx2")]
5287 const fn test_mm256_srli_epi16() {
5288 assert_eq_m256i(
5289 _mm256_srli_epi16::<4>(_mm256_set1_epi16(0xFF)),
5290 _mm256_set1_epi16(0xF),
5291 );
5292 }
5293
5294 #[simd_test(enable = "avx2")]
5295 const fn test_mm256_srli_epi32() {
5296 assert_eq_m256i(
5297 _mm256_srli_epi32::<4>(_mm256_set1_epi32(0xFFFF)),
5298 _mm256_set1_epi32(0xFFF),
5299 );
5300 }
5301
5302 #[simd_test(enable = "avx2")]
5303 const fn test_mm256_srli_epi64() {
5304 assert_eq_m256i(
5305 _mm256_srli_epi64::<4>(_mm256_set1_epi64x(0xFFFFFFFF)),
5306 _mm256_set1_epi64x(0xFFFFFFF),
5307 );
5308 }
5309
5310 #[simd_test(enable = "avx2")]
5311 fn test_mm_srlv_epi32() {
5312 let a = _mm_set1_epi32(2);
5313 let count = _mm_set1_epi32(1);
5314 let r = _mm_srlv_epi32(a, count);
5315 let e = _mm_set1_epi32(1);
5316 assert_eq_m128i(r, e);
5317 }
5318
5319 #[simd_test(enable = "avx2")]
5320 fn test_mm256_srlv_epi32() {
5321 let a = _mm256_set1_epi32(2);
5322 let count = _mm256_set1_epi32(1);
5323 let r = _mm256_srlv_epi32(a, count);
5324 let e = _mm256_set1_epi32(1);
5325 assert_eq_m256i(r, e);
5326 }
5327
5328 #[simd_test(enable = "avx2")]
5329 fn test_mm_srlv_epi64() {
5330 let a = _mm_set_epi64x(4, 8);
5331 let b = _mm_set_epi64x(2, 1);
5332 let r = _mm_srlv_epi64(a, b);
5333 let e = _mm_set_epi64x(4i64.unbounded_shr(2), 8i64.unbounded_shr(1));
5335 assert_eq_m128i(r, e);
5336 let e = _mm_set_epi64x(1, 4);
5338 assert_eq_m128i(r, e);
5339
5340 let a = _mm_set_epi64x(i64::MAX, i64::MAX);
5343 let b = _mm_set_epi64x(64, 65);
5344 let r = _mm_sllv_epi64(a, b);
5345 let e = _mm_set_epi64x(i64::MAX.unbounded_shr(64), i64::MAX.unbounded_shr(65));
5346 assert_eq_m128i(r, e);
5347 let e = _mm_set_epi64x(0, 0);
5348 assert_eq_m128i(r, e);
5349 }
5350
5351 #[simd_test(enable = "avx2")]
5352 fn test_mm256_srlv_epi64() {
5353 let a = _mm256_set1_epi64x(2);
5354 let count = _mm256_set1_epi64x(1);
5355 let r = _mm256_srlv_epi64(a, count);
5356 let e = _mm256_set1_epi64x(1);
5357 assert_eq_m256i(r, e);
5358 }
5359
5360 #[simd_test(enable = "avx2")]
5361 fn test_mm256_stream_load_si256() {
5362 let a = _mm256_set_epi64x(5, 6, 7, 8);
5363 let r = unsafe { _mm256_stream_load_si256(core::ptr::addr_of!(a) as *const _) };
5364 assert_eq_m256i(a, r);
5365 }
5366
5367 #[simd_test(enable = "avx2")]
5368 const fn test_mm256_sub_epi16() {
5369 let a = _mm256_set1_epi16(4);
5370 let b = _mm256_set1_epi16(2);
5371 let r = _mm256_sub_epi16(a, b);
5372 assert_eq_m256i(r, b);
5373 }
5374
5375 #[simd_test(enable = "avx2")]
5376 const fn test_mm256_sub_epi32() {
5377 let a = _mm256_set1_epi32(4);
5378 let b = _mm256_set1_epi32(2);
5379 let r = _mm256_sub_epi32(a, b);
5380 assert_eq_m256i(r, b);
5381 }
5382
5383 #[simd_test(enable = "avx2")]
5384 const fn test_mm256_sub_epi64() {
5385 let a = _mm256_set1_epi64x(4);
5386 let b = _mm256_set1_epi64x(2);
5387 let r = _mm256_sub_epi64(a, b);
5388 assert_eq_m256i(r, b);
5389 }
5390
5391 #[simd_test(enable = "avx2")]
5392 const fn test_mm256_sub_epi8() {
5393 let a = _mm256_set1_epi8(4);
5394 let b = _mm256_set1_epi8(2);
5395 let r = _mm256_sub_epi8(a, b);
5396 assert_eq_m256i(r, b);
5397 }
5398
5399 #[simd_test(enable = "avx2")]
5400 const fn test_mm256_subs_epi16() {
5401 let a = _mm256_set1_epi16(4);
5402 let b = _mm256_set1_epi16(2);
5403 let r = _mm256_subs_epi16(a, b);
5404 assert_eq_m256i(r, b);
5405 }
5406
5407 #[simd_test(enable = "avx2")]
5408 const fn test_mm256_subs_epi8() {
5409 let a = _mm256_set1_epi8(4);
5410 let b = _mm256_set1_epi8(2);
5411 let r = _mm256_subs_epi8(a, b);
5412 assert_eq_m256i(r, b);
5413 }
5414
5415 #[simd_test(enable = "avx2")]
5416 const fn test_mm256_subs_epu16() {
5417 let a = _mm256_set1_epi16(4);
5418 let b = _mm256_set1_epi16(2);
5419 let r = _mm256_subs_epu16(a, b);
5420 assert_eq_m256i(r, b);
5421 }
5422
5423 #[simd_test(enable = "avx2")]
5424 const fn test_mm256_subs_epu8() {
5425 let a = _mm256_set1_epi8(4);
5426 let b = _mm256_set1_epi8(2);
5427 let r = _mm256_subs_epu8(a, b);
5428 assert_eq_m256i(r, b);
5429 }
5430
5431 #[simd_test(enable = "avx2")]
5432 const fn test_mm256_xor_si256() {
5433 let a = _mm256_set1_epi8(5);
5434 let b = _mm256_set1_epi8(3);
5435 let r = _mm256_xor_si256(a, b);
5436 assert_eq_m256i(r, _mm256_set1_epi8(6));
5437 }
5438
5439 #[simd_test(enable = "avx2")]
5440 const fn test_mm256_alignr_epi8() {
5441 #[rustfmt::skip]
5442 let a = _mm256_setr_epi8(
5443 1, 2, 3, 4, 5, 6, 7, 8,
5444 9, 10, 11, 12, 13, 14, 15, 16,
5445 17, 18, 19, 20, 21, 22, 23, 24,
5446 25, 26, 27, 28, 29, 30, 31, 32,
5447 );
5448 #[rustfmt::skip]
5449 let b = _mm256_setr_epi8(
5450 -1, -2, -3, -4, -5, -6, -7, -8,
5451 -9, -10, -11, -12, -13, -14, -15, -16,
5452 -17, -18, -19, -20, -21, -22, -23, -24,
5453 -25, -26, -27, -28, -29, -30, -31, -32,
5454 );
5455 let r = _mm256_alignr_epi8::<33>(a, b);
5456 assert_eq_m256i(r, _mm256_set1_epi8(0));
5457
5458 let r = _mm256_alignr_epi8::<17>(a, b);
5459 #[rustfmt::skip]
5460 let expected = _mm256_setr_epi8(
5461 2, 3, 4, 5, 6, 7, 8, 9,
5462 10, 11, 12, 13, 14, 15, 16, 0,
5463 18, 19, 20, 21, 22, 23, 24, 25,
5464 26, 27, 28, 29, 30, 31, 32, 0,
5465 );
5466 assert_eq_m256i(r, expected);
5467
5468 let r = _mm256_alignr_epi8::<4>(a, b);
5469 #[rustfmt::skip]
5470 let expected = _mm256_setr_epi8(
5471 -5, -6, -7, -8, -9, -10, -11, -12,
5472 -13, -14, -15, -16, 1, 2, 3, 4,
5473 -21, -22, -23, -24, -25, -26, -27, -28,
5474 -29, -30, -31, -32, 17, 18, 19, 20,
5475 );
5476 assert_eq_m256i(r, expected);
5477
5478 let r = _mm256_alignr_epi8::<15>(a, b);
5479 #[rustfmt::skip]
5480 let expected = _mm256_setr_epi8(
5481 -16, 1, 2, 3, 4, 5, 6, 7,
5482 8, 9, 10, 11, 12, 13, 14, 15,
5483 -32, 17, 18, 19, 20, 21, 22, 23,
5484 24, 25, 26, 27, 28, 29, 30, 31,
5485 );
5486 assert_eq_m256i(r, expected);
5487
5488 let r = _mm256_alignr_epi8::<0>(a, b);
5489 assert_eq_m256i(r, b);
5490
5491 let r = _mm256_alignr_epi8::<16>(a, b);
5492 assert_eq_m256i(r, a);
5493 }
5494
5495 #[simd_test(enable = "avx2")]
5496 fn test_mm256_shuffle_epi8() {
5497 #[rustfmt::skip]
5498 let a = _mm256_setr_epi8(
5499 1, 2, 3, 4, 5, 6, 7, 8,
5500 9, 10, 11, 12, 13, 14, 15, 16,
5501 17, 18, 19, 20, 21, 22, 23, 24,
5502 25, 26, 27, 28, 29, 30, 31, 32,
5503 );
5504 #[rustfmt::skip]
5505 let b = _mm256_setr_epi8(
5506 4, 128u8 as i8, 4, 3, 24, 12, 6, 19,
5507 12, 5, 5, 10, 4, 1, 8, 0,
5508 4, 128u8 as i8, 4, 3, 24, 12, 6, 19,
5509 12, 5, 5, 10, 4, 1, 8, 0,
5510 );
5511 #[rustfmt::skip]
5512 let expected = _mm256_setr_epi8(
5513 5, 0, 5, 4, 9, 13, 7, 4,
5514 13, 6, 6, 11, 5, 2, 9, 1,
5515 21, 0, 21, 20, 25, 29, 23, 20,
5516 29, 22, 22, 27, 21, 18, 25, 17,
5517 );
5518 let r = _mm256_shuffle_epi8(a, b);
5519 assert_eq_m256i(r, expected);
5520 }
5521
5522 #[simd_test(enable = "avx2")]
5523 fn test_mm256_permutevar8x32_epi32() {
5524 let a = _mm256_setr_epi32(100, 200, 300, 400, 500, 600, 700, 800);
5525 let b = _mm256_setr_epi32(5, 0, 5, 1, 7, 6, 3, 4);
5526 let expected = _mm256_setr_epi32(600, 100, 600, 200, 800, 700, 400, 500);
5527 let r = _mm256_permutevar8x32_epi32(a, b);
5528 assert_eq_m256i(r, expected);
5529 }
5530
5531 #[simd_test(enable = "avx2")]
5532 const fn test_mm256_permute4x64_epi64() {
5533 let a = _mm256_setr_epi64x(100, 200, 300, 400);
5534 let expected = _mm256_setr_epi64x(400, 100, 200, 100);
5535 let r = _mm256_permute4x64_epi64::<0b00010011>(a);
5536 assert_eq_m256i(r, expected);
5537 }
5538
5539 #[simd_test(enable = "avx2")]
5540 const fn test_mm256_permute2x128_si256() {
5541 let a = _mm256_setr_epi64x(100, 200, 500, 600);
5542 let b = _mm256_setr_epi64x(300, 400, 700, 800);
5543 let r = _mm256_permute2x128_si256::<0b00_01_00_11>(a, b);
5544 let e = _mm256_setr_epi64x(700, 800, 500, 600);
5545 assert_eq_m256i(r, e);
5546 }
5547
5548 #[simd_test(enable = "avx2")]
5549 const fn test_mm256_permute4x64_pd() {
5550 let a = _mm256_setr_pd(1., 2., 3., 4.);
5551 let r = _mm256_permute4x64_pd::<0b00_01_00_11>(a);
5552 let e = _mm256_setr_pd(4., 1., 2., 1.);
5553 assert_eq_m256d(r, e);
5554 }
5555
5556 #[simd_test(enable = "avx2")]
5557 fn test_mm256_permutevar8x32_ps() {
5558 let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.);
5559 let b = _mm256_setr_epi32(5, 0, 5, 1, 7, 6, 3, 4);
5560 let r = _mm256_permutevar8x32_ps(a, b);
5561 let e = _mm256_setr_ps(6., 1., 6., 2., 8., 7., 4., 5.);
5562 assert_eq_m256(r, e);
5563 }
5564
5565 #[simd_test(enable = "avx2")]
5566 fn test_mm_i32gather_epi32() {
5567 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5568 let r = unsafe { _mm_i32gather_epi32::<4>(arr.as_ptr(), _mm_setr_epi32(0, 16, 32, 48)) };
5570 assert_eq_m128i(r, _mm_setr_epi32(0, 16, 32, 48));
5571 }
5572
5573 #[simd_test(enable = "avx2")]
5574 fn test_mm_mask_i32gather_epi32() {
5575 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5576 let r = unsafe {
5578 _mm_mask_i32gather_epi32::<4>(
5579 _mm_set1_epi32(256),
5580 arr.as_ptr(),
5581 _mm_setr_epi32(0, 16, 64, 96),
5582 _mm_setr_epi32(-1, -1, -1, 0),
5583 )
5584 };
5585 assert_eq_m128i(r, _mm_setr_epi32(0, 16, 64, 256));
5586 }
5587
5588 #[simd_test(enable = "avx2")]
5589 fn test_mm256_i32gather_epi32() {
5590 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5591 let r = unsafe {
5593 _mm256_i32gather_epi32::<4>(arr.as_ptr(), _mm256_setr_epi32(0, 16, 32, 48, 1, 2, 3, 4))
5594 };
5595 assert_eq_m256i(r, _mm256_setr_epi32(0, 16, 32, 48, 1, 2, 3, 4));
5596 }
5597
5598 #[simd_test(enable = "avx2")]
5599 fn test_mm256_mask_i32gather_epi32() {
5600 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5601 let r = unsafe {
5603 _mm256_mask_i32gather_epi32::<4>(
5604 _mm256_set1_epi32(256),
5605 arr.as_ptr(),
5606 _mm256_setr_epi32(0, 16, 64, 96, 0, 0, 0, 0),
5607 _mm256_setr_epi32(-1, -1, -1, 0, 0, 0, 0, 0),
5608 )
5609 };
5610 assert_eq_m256i(r, _mm256_setr_epi32(0, 16, 64, 256, 256, 256, 256, 256));
5611 }
5612
5613 #[simd_test(enable = "avx2")]
5614 fn test_mm_i32gather_ps() {
5615 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5616 let r = unsafe { _mm_i32gather_ps::<4>(arr.as_ptr(), _mm_setr_epi32(0, 16, 32, 48)) };
5618 assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 32.0, 48.0));
5619 }
5620
5621 #[simd_test(enable = "avx2")]
5622 fn test_mm_mask_i32gather_ps() {
5623 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5624 let r = unsafe {
5626 _mm_mask_i32gather_ps::<4>(
5627 _mm_set1_ps(256.0),
5628 arr.as_ptr(),
5629 _mm_setr_epi32(0, 16, 64, 96),
5630 _mm_setr_ps(-1.0, -1.0, -1.0, 0.0),
5631 )
5632 };
5633 assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 64.0, 256.0));
5634 }
5635
5636 #[simd_test(enable = "avx2")]
5637 fn test_mm256_i32gather_ps() {
5638 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5639 let r = unsafe {
5641 _mm256_i32gather_ps::<4>(arr.as_ptr(), _mm256_setr_epi32(0, 16, 32, 48, 1, 2, 3, 4))
5642 };
5643 assert_eq_m256(r, _mm256_setr_ps(0.0, 16.0, 32.0, 48.0, 1.0, 2.0, 3.0, 4.0));
5644 }
5645
5646 #[simd_test(enable = "avx2")]
5647 fn test_mm256_mask_i32gather_ps() {
5648 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5649 let r = unsafe {
5651 _mm256_mask_i32gather_ps::<4>(
5652 _mm256_set1_ps(256.0),
5653 arr.as_ptr(),
5654 _mm256_setr_epi32(0, 16, 64, 96, 0, 0, 0, 0),
5655 _mm256_setr_ps(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0),
5656 )
5657 };
5658 assert_eq_m256(
5659 r,
5660 _mm256_setr_ps(0.0, 16.0, 64.0, 256.0, 256.0, 256.0, 256.0, 256.0),
5661 );
5662 }
5663
5664 #[simd_test(enable = "avx2")]
5665 fn test_mm_i32gather_epi64() {
5666 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5667 let r = unsafe { _mm_i32gather_epi64::<8>(arr.as_ptr(), _mm_setr_epi32(0, 16, 0, 0)) };
5669 assert_eq_m128i(r, _mm_setr_epi64x(0, 16));
5670 }
5671
5672 #[simd_test(enable = "avx2")]
5673 fn test_mm_mask_i32gather_epi64() {
5674 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5675 let r = unsafe {
5677 _mm_mask_i32gather_epi64::<8>(
5678 _mm_set1_epi64x(256),
5679 arr.as_ptr(),
5680 _mm_setr_epi32(16, 16, 16, 16),
5681 _mm_setr_epi64x(-1, 0),
5682 )
5683 };
5684 assert_eq_m128i(r, _mm_setr_epi64x(16, 256));
5685 }
5686
5687 #[simd_test(enable = "avx2")]
5688 fn test_mm256_i32gather_epi64() {
5689 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5690 let r = unsafe { _mm256_i32gather_epi64::<8>(arr.as_ptr(), _mm_setr_epi32(0, 16, 32, 48)) };
5692 assert_eq_m256i(r, _mm256_setr_epi64x(0, 16, 32, 48));
5693 }
5694
5695 #[simd_test(enable = "avx2")]
5696 fn test_mm256_mask_i32gather_epi64() {
5697 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5698 let r = unsafe {
5700 _mm256_mask_i32gather_epi64::<8>(
5701 _mm256_set1_epi64x(256),
5702 arr.as_ptr(),
5703 _mm_setr_epi32(0, 16, 64, 96),
5704 _mm256_setr_epi64x(-1, -1, -1, 0),
5705 )
5706 };
5707 assert_eq_m256i(r, _mm256_setr_epi64x(0, 16, 64, 256));
5708 }
5709
5710 #[simd_test(enable = "avx2")]
5711 fn test_mm_i32gather_pd() {
5712 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5713 let r = unsafe { _mm_i32gather_pd::<8>(arr.as_ptr(), _mm_setr_epi32(0, 16, 0, 0)) };
5715 assert_eq_m128d(r, _mm_setr_pd(0.0, 16.0));
5716 }
5717
5718 #[simd_test(enable = "avx2")]
5719 fn test_mm_mask_i32gather_pd() {
5720 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5721 let r = unsafe {
5723 _mm_mask_i32gather_pd::<8>(
5724 _mm_set1_pd(256.0),
5725 arr.as_ptr(),
5726 _mm_setr_epi32(16, 16, 16, 16),
5727 _mm_setr_pd(-1.0, 0.0),
5728 )
5729 };
5730 assert_eq_m128d(r, _mm_setr_pd(16.0, 256.0));
5731 }
5732
5733 #[simd_test(enable = "avx2")]
5734 fn test_mm256_i32gather_pd() {
5735 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5736 let r = unsafe { _mm256_i32gather_pd::<8>(arr.as_ptr(), _mm_setr_epi32(0, 16, 32, 48)) };
5738 assert_eq_m256d(r, _mm256_setr_pd(0.0, 16.0, 32.0, 48.0));
5739 }
5740
5741 #[simd_test(enable = "avx2")]
5742 fn test_mm256_mask_i32gather_pd() {
5743 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5744 let r = unsafe {
5746 _mm256_mask_i32gather_pd::<8>(
5747 _mm256_set1_pd(256.0),
5748 arr.as_ptr(),
5749 _mm_setr_epi32(0, 16, 64, 96),
5750 _mm256_setr_pd(-1.0, -1.0, -1.0, 0.0),
5751 )
5752 };
5753 assert_eq_m256d(r, _mm256_setr_pd(0.0, 16.0, 64.0, 256.0));
5754 }
5755
5756 #[simd_test(enable = "avx2")]
5757 fn test_mm_i64gather_epi32() {
5758 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5759 let r = unsafe { _mm_i64gather_epi32::<4>(arr.as_ptr(), _mm_setr_epi64x(0, 16)) };
5761 assert_eq_m128i(r, _mm_setr_epi32(0, 16, 0, 0));
5762 }
5763
5764 #[simd_test(enable = "avx2")]
5765 fn test_mm_mask_i64gather_epi32() {
5766 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5767 let r = unsafe {
5769 _mm_mask_i64gather_epi32::<4>(
5770 _mm_set1_epi32(256),
5771 arr.as_ptr(),
5772 _mm_setr_epi64x(0, 16),
5773 _mm_setr_epi32(-1, 0, -1, 0),
5774 )
5775 };
5776 assert_eq_m128i(r, _mm_setr_epi32(0, 256, 0, 0));
5777 }
5778
5779 #[simd_test(enable = "avx2")]
5780 fn test_mm256_i64gather_epi32() {
5781 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5782 let r =
5784 unsafe { _mm256_i64gather_epi32::<4>(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48)) };
5785 assert_eq_m128i(r, _mm_setr_epi32(0, 16, 32, 48));
5786 }
5787
5788 #[simd_test(enable = "avx2")]
5789 fn test_mm256_mask_i64gather_epi32() {
5790 let arr: [i32; 128] = core::array::from_fn(|i| i as i32);
5791 let r = unsafe {
5793 _mm256_mask_i64gather_epi32::<4>(
5794 _mm_set1_epi32(256),
5795 arr.as_ptr(),
5796 _mm256_setr_epi64x(0, 16, 64, 96),
5797 _mm_setr_epi32(-1, -1, -1, 0),
5798 )
5799 };
5800 assert_eq_m128i(r, _mm_setr_epi32(0, 16, 64, 256));
5801 }
5802
5803 #[simd_test(enable = "avx2")]
5804 fn test_mm_i64gather_ps() {
5805 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5806 let r = unsafe { _mm_i64gather_ps::<4>(arr.as_ptr(), _mm_setr_epi64x(0, 16)) };
5808 assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 0.0, 0.0));
5809 }
5810
5811 #[simd_test(enable = "avx2")]
5812 fn test_mm_mask_i64gather_ps() {
5813 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5814 let r = unsafe {
5816 _mm_mask_i64gather_ps::<4>(
5817 _mm_set1_ps(256.0),
5818 arr.as_ptr(),
5819 _mm_setr_epi64x(0, 16),
5820 _mm_setr_ps(-1.0, 0.0, -1.0, 0.0),
5821 )
5822 };
5823 assert_eq_m128(r, _mm_setr_ps(0.0, 256.0, 0.0, 0.0));
5824 }
5825
5826 #[simd_test(enable = "avx2")]
5827 fn test_mm256_i64gather_ps() {
5828 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5829 let r =
5831 unsafe { _mm256_i64gather_ps::<4>(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48)) };
5832 assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 32.0, 48.0));
5833 }
5834
5835 #[simd_test(enable = "avx2")]
5836 fn test_mm256_mask_i64gather_ps() {
5837 let arr: [f32; 128] = core::array::from_fn(|i| i as f32);
5838 let r = unsafe {
5840 _mm256_mask_i64gather_ps::<4>(
5841 _mm_set1_ps(256.0),
5842 arr.as_ptr(),
5843 _mm256_setr_epi64x(0, 16, 64, 96),
5844 _mm_setr_ps(-1.0, -1.0, -1.0, 0.0),
5845 )
5846 };
5847 assert_eq_m128(r, _mm_setr_ps(0.0, 16.0, 64.0, 256.0));
5848 }
5849
5850 #[simd_test(enable = "avx2")]
5851 fn test_mm_i64gather_epi64() {
5852 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5853 let r = unsafe { _mm_i64gather_epi64::<8>(arr.as_ptr(), _mm_setr_epi64x(0, 16)) };
5855 assert_eq_m128i(r, _mm_setr_epi64x(0, 16));
5856 }
5857
5858 #[simd_test(enable = "avx2")]
5859 fn test_mm_mask_i64gather_epi64() {
5860 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5861 let r = unsafe {
5863 _mm_mask_i64gather_epi64::<8>(
5864 _mm_set1_epi64x(256),
5865 arr.as_ptr(),
5866 _mm_setr_epi64x(16, 16),
5867 _mm_setr_epi64x(-1, 0),
5868 )
5869 };
5870 assert_eq_m128i(r, _mm_setr_epi64x(16, 256));
5871 }
5872
5873 #[simd_test(enable = "avx2")]
5874 fn test_mm256_i64gather_epi64() {
5875 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5876 let r =
5878 unsafe { _mm256_i64gather_epi64::<8>(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48)) };
5879 assert_eq_m256i(r, _mm256_setr_epi64x(0, 16, 32, 48));
5880 }
5881
5882 #[simd_test(enable = "avx2")]
5883 fn test_mm256_mask_i64gather_epi64() {
5884 let arr: [i64; 128] = core::array::from_fn(|i| i as i64);
5885 let r = unsafe {
5887 _mm256_mask_i64gather_epi64::<8>(
5888 _mm256_set1_epi64x(256),
5889 arr.as_ptr(),
5890 _mm256_setr_epi64x(0, 16, 64, 96),
5891 _mm256_setr_epi64x(-1, -1, -1, 0),
5892 )
5893 };
5894 assert_eq_m256i(r, _mm256_setr_epi64x(0, 16, 64, 256));
5895 }
5896
5897 #[simd_test(enable = "avx2")]
5898 fn test_mm_i64gather_pd() {
5899 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5900 let r = unsafe { _mm_i64gather_pd::<8>(arr.as_ptr(), _mm_setr_epi64x(0, 16)) };
5902 assert_eq_m128d(r, _mm_setr_pd(0.0, 16.0));
5903 }
5904
5905 #[simd_test(enable = "avx2")]
5906 fn test_mm_mask_i64gather_pd() {
5907 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5908 let r = unsafe {
5910 _mm_mask_i64gather_pd::<8>(
5911 _mm_set1_pd(256.0),
5912 arr.as_ptr(),
5913 _mm_setr_epi64x(16, 16),
5914 _mm_setr_pd(-1.0, 0.0),
5915 )
5916 };
5917 assert_eq_m128d(r, _mm_setr_pd(16.0, 256.0));
5918 }
5919
5920 #[simd_test(enable = "avx2")]
5921 fn test_mm256_i64gather_pd() {
5922 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5923 let r =
5925 unsafe { _mm256_i64gather_pd::<8>(arr.as_ptr(), _mm256_setr_epi64x(0, 16, 32, 48)) };
5926 assert_eq_m256d(r, _mm256_setr_pd(0.0, 16.0, 32.0, 48.0));
5927 }
5928
5929 #[simd_test(enable = "avx2")]
5930 fn test_mm256_mask_i64gather_pd() {
5931 let arr: [f64; 128] = core::array::from_fn(|i| i as f64);
5932 let r = unsafe {
5934 _mm256_mask_i64gather_pd::<8>(
5935 _mm256_set1_pd(256.0),
5936 arr.as_ptr(),
5937 _mm256_setr_epi64x(0, 16, 64, 96),
5938 _mm256_setr_pd(-1.0, -1.0, -1.0, 0.0),
5939 )
5940 };
5941 assert_eq_m256d(r, _mm256_setr_pd(0.0, 16.0, 64.0, 256.0));
5942 }
5943
5944 #[simd_test(enable = "avx2")]
5945 const fn test_mm256_extract_epi8() {
5946 #[rustfmt::skip]
5947 let a = _mm256_setr_epi8(
5948 -1, 1, 2, 3, 4, 5, 6, 7,
5949 8, 9, 10, 11, 12, 13, 14, 15,
5950 16, 17, 18, 19, 20, 21, 22, 23,
5951 24, 25, 26, 27, 28, 29, 30, 31
5952 );
5953 let r1 = _mm256_extract_epi8::<0>(a);
5954 let r2 = _mm256_extract_epi8::<3>(a);
5955 assert_eq!(r1, 0xFF);
5956 assert_eq!(r2, 3);
5957 }
5958
5959 #[simd_test(enable = "avx2")]
5960 const fn test_mm256_extract_epi16() {
5961 #[rustfmt::skip]
5962 let a = _mm256_setr_epi16(
5963 -1, 1, 2, 3, 4, 5, 6, 7,
5964 8, 9, 10, 11, 12, 13, 14, 15,
5965 );
5966 let r1 = _mm256_extract_epi16::<0>(a);
5967 let r2 = _mm256_extract_epi16::<3>(a);
5968 assert_eq!(r1, 0xFFFF);
5969 assert_eq!(r2, 3);
5970 }
5971}