1#[cfg(test)]
4use stdarch_test::assert_instr;
5
6use crate::{
7 core_arch::{simd::*, x86::*},
8 intrinsics::simd::*,
9 intrinsics::sqrt,
10 mem, ptr,
11};
12
13#[inline]
20#[cfg_attr(all(test, target_feature = "sse2"), assert_instr(pause))]
21#[stable(feature = "simd_x86", since = "1.27.0")]
22pub fn _mm_pause() {
23 unsafe { pause() }
26}
27
28#[inline]
39#[target_feature(enable = "sse2")]
40#[cfg_attr(test, assert_instr(clflush))]
41#[stable(feature = "simd_x86", since = "1.27.0")]
42pub unsafe fn _mm_clflush(p: *const u8) {
43 clflush(p)
44}
45
46#[inline]
55#[target_feature(enable = "sse2")]
56#[cfg_attr(test, assert_instr(lfence))]
57#[stable(feature = "simd_x86", since = "1.27.0")]
58pub fn _mm_lfence() {
59 unsafe { lfence() }
60}
61
62#[inline]
71#[target_feature(enable = "sse2")]
72#[cfg_attr(test, assert_instr(mfence))]
73#[stable(feature = "simd_x86", since = "1.27.0")]
74pub fn _mm_mfence() {
75 unsafe { mfence() }
76}
77
78#[inline]
82#[target_feature(enable = "sse2")]
83#[cfg_attr(test, assert_instr(paddb))]
84#[stable(feature = "simd_x86", since = "1.27.0")]
85#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
86pub const fn _mm_add_epi8(a: __m128i, b: __m128i) -> __m128i {
87 unsafe { transmute(simd_add(a.as_i8x16(), b.as_i8x16())) }
88}
89
90#[inline]
94#[target_feature(enable = "sse2")]
95#[cfg_attr(test, assert_instr(paddw))]
96#[stable(feature = "simd_x86", since = "1.27.0")]
97#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
98pub const fn _mm_add_epi16(a: __m128i, b: __m128i) -> __m128i {
99 unsafe { transmute(simd_add(a.as_i16x8(), b.as_i16x8())) }
100}
101
102#[inline]
106#[target_feature(enable = "sse2")]
107#[cfg_attr(test, assert_instr(paddd))]
108#[stable(feature = "simd_x86", since = "1.27.0")]
109#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
110pub const fn _mm_add_epi32(a: __m128i, b: __m128i) -> __m128i {
111 unsafe { transmute(simd_add(a.as_i32x4(), b.as_i32x4())) }
112}
113
114#[inline]
118#[target_feature(enable = "sse2")]
119#[cfg_attr(test, assert_instr(paddq))]
120#[stable(feature = "simd_x86", since = "1.27.0")]
121#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
122pub const fn _mm_add_epi64(a: __m128i, b: __m128i) -> __m128i {
123 unsafe { transmute(simd_add(a.as_i64x2(), b.as_i64x2())) }
124}
125
126#[inline]
130#[target_feature(enable = "sse2")]
131#[cfg_attr(test, assert_instr(paddsb))]
132#[stable(feature = "simd_x86", since = "1.27.0")]
133#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
134pub const fn _mm_adds_epi8(a: __m128i, b: __m128i) -> __m128i {
135 unsafe { transmute(simd_saturating_add(a.as_i8x16(), b.as_i8x16())) }
136}
137
138#[inline]
142#[target_feature(enable = "sse2")]
143#[cfg_attr(test, assert_instr(paddsw))]
144#[stable(feature = "simd_x86", since = "1.27.0")]
145#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
146pub const fn _mm_adds_epi16(a: __m128i, b: __m128i) -> __m128i {
147 unsafe { transmute(simd_saturating_add(a.as_i16x8(), b.as_i16x8())) }
148}
149
150#[inline]
154#[target_feature(enable = "sse2")]
155#[cfg_attr(test, assert_instr(paddusb))]
156#[stable(feature = "simd_x86", since = "1.27.0")]
157#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
158pub const fn _mm_adds_epu8(a: __m128i, b: __m128i) -> __m128i {
159 unsafe { transmute(simd_saturating_add(a.as_u8x16(), b.as_u8x16())) }
160}
161
162#[inline]
166#[target_feature(enable = "sse2")]
167#[cfg_attr(test, assert_instr(paddusw))]
168#[stable(feature = "simd_x86", since = "1.27.0")]
169#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
170pub const fn _mm_adds_epu16(a: __m128i, b: __m128i) -> __m128i {
171 unsafe { transmute(simd_saturating_add(a.as_u16x8(), b.as_u16x8())) }
172}
173
174#[inline]
178#[target_feature(enable = "sse2")]
179#[cfg_attr(test, assert_instr(pavgb))]
180#[stable(feature = "simd_x86", since = "1.27.0")]
181pub fn _mm_avg_epu8(a: __m128i, b: __m128i) -> __m128i {
182 unsafe { transmute(pavgb(a.as_u8x16(), b.as_u8x16())) }
183}
184
185#[inline]
189#[target_feature(enable = "sse2")]
190#[cfg_attr(test, assert_instr(pavgw))]
191#[stable(feature = "simd_x86", since = "1.27.0")]
192pub fn _mm_avg_epu16(a: __m128i, b: __m128i) -> __m128i {
193 unsafe { transmute(pavgw(a.as_u16x8(), b.as_u16x8())) }
194}
195
196#[inline]
204#[target_feature(enable = "sse2")]
205#[cfg_attr(test, assert_instr(pmaddwd))]
206#[stable(feature = "simd_x86", since = "1.27.0")]
207pub fn _mm_madd_epi16(a: __m128i, b: __m128i) -> __m128i {
208 unsafe { transmute(pmaddwd(a.as_i16x8(), b.as_i16x8())) }
221}
222
223#[inline]
228#[target_feature(enable = "sse2")]
229#[cfg_attr(test, assert_instr(pmaxsw))]
230#[stable(feature = "simd_x86", since = "1.27.0")]
231#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
232pub const fn _mm_max_epi16(a: __m128i, b: __m128i) -> __m128i {
233 unsafe { simd_imax(a.as_i16x8(), b.as_i16x8()).as_m128i() }
234}
235
236#[inline]
241#[target_feature(enable = "sse2")]
242#[cfg_attr(test, assert_instr(pmaxub))]
243#[stable(feature = "simd_x86", since = "1.27.0")]
244#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
245pub const fn _mm_max_epu8(a: __m128i, b: __m128i) -> __m128i {
246 unsafe { simd_imax(a.as_u8x16(), b.as_u8x16()).as_m128i() }
247}
248
249#[inline]
254#[target_feature(enable = "sse2")]
255#[cfg_attr(test, assert_instr(pminsw))]
256#[stable(feature = "simd_x86", since = "1.27.0")]
257#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
258pub const fn _mm_min_epi16(a: __m128i, b: __m128i) -> __m128i {
259 unsafe { simd_imin(a.as_i16x8(), b.as_i16x8()).as_m128i() }
260}
261
262#[inline]
267#[target_feature(enable = "sse2")]
268#[cfg_attr(test, assert_instr(pminub))]
269#[stable(feature = "simd_x86", since = "1.27.0")]
270#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
271pub const fn _mm_min_epu8(a: __m128i, b: __m128i) -> __m128i {
272 unsafe { simd_imin(a.as_u8x16(), b.as_u8x16()).as_m128i() }
273}
274
275#[inline]
282#[target_feature(enable = "sse2")]
283#[cfg_attr(test, assert_instr(pmulhw))]
284#[stable(feature = "simd_x86", since = "1.27.0")]
285pub fn _mm_mulhi_epi16(a: __m128i, b: __m128i) -> __m128i {
286 unsafe { transmute(pmulhw(a.as_i16x8(), b.as_i16x8())) }
287}
288
289#[inline]
296#[target_feature(enable = "sse2")]
297#[cfg_attr(test, assert_instr(pmulhuw))]
298#[stable(feature = "simd_x86", since = "1.27.0")]
299pub fn _mm_mulhi_epu16(a: __m128i, b: __m128i) -> __m128i {
300 unsafe { transmute(pmulhuw(a.as_u16x8(), b.as_u16x8())) }
301}
302
303#[inline]
310#[target_feature(enable = "sse2")]
311#[cfg_attr(test, assert_instr(pmullw))]
312#[stable(feature = "simd_x86", since = "1.27.0")]
313#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
314pub const fn _mm_mullo_epi16(a: __m128i, b: __m128i) -> __m128i {
315 unsafe { transmute(simd_mul(a.as_i16x8(), b.as_i16x8())) }
316}
317
318#[inline]
325#[target_feature(enable = "sse2")]
326#[cfg_attr(test, assert_instr(pmuludq))]
327#[stable(feature = "simd_x86", since = "1.27.0")]
328#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
329pub const fn _mm_mul_epu32(a: __m128i, b: __m128i) -> __m128i {
330 unsafe {
331 let a = a.as_u64x2();
332 let b = b.as_u64x2();
333 let mask = u64x2::splat(u32::MAX as u64);
334 transmute(simd_mul(simd_and(a, mask), simd_and(b, mask)))
335 }
336}
337
338#[inline]
347#[target_feature(enable = "sse2")]
348#[cfg_attr(test, assert_instr(psadbw))]
349#[stable(feature = "simd_x86", since = "1.27.0")]
350pub fn _mm_sad_epu8(a: __m128i, b: __m128i) -> __m128i {
351 unsafe { transmute(psadbw(a.as_u8x16(), b.as_u8x16())) }
352}
353
354#[inline]
358#[target_feature(enable = "sse2")]
359#[cfg_attr(test, assert_instr(psubb))]
360#[stable(feature = "simd_x86", since = "1.27.0")]
361#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
362pub const fn _mm_sub_epi8(a: __m128i, b: __m128i) -> __m128i {
363 unsafe { transmute(simd_sub(a.as_i8x16(), b.as_i8x16())) }
364}
365
366#[inline]
370#[target_feature(enable = "sse2")]
371#[cfg_attr(test, assert_instr(psubw))]
372#[stable(feature = "simd_x86", since = "1.27.0")]
373#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
374pub const fn _mm_sub_epi16(a: __m128i, b: __m128i) -> __m128i {
375 unsafe { transmute(simd_sub(a.as_i16x8(), b.as_i16x8())) }
376}
377
378#[inline]
382#[target_feature(enable = "sse2")]
383#[cfg_attr(test, assert_instr(psubd))]
384#[stable(feature = "simd_x86", since = "1.27.0")]
385#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
386pub const fn _mm_sub_epi32(a: __m128i, b: __m128i) -> __m128i {
387 unsafe { transmute(simd_sub(a.as_i32x4(), b.as_i32x4())) }
388}
389
390#[inline]
394#[target_feature(enable = "sse2")]
395#[cfg_attr(test, assert_instr(psubq))]
396#[stable(feature = "simd_x86", since = "1.27.0")]
397#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
398pub const fn _mm_sub_epi64(a: __m128i, b: __m128i) -> __m128i {
399 unsafe { transmute(simd_sub(a.as_i64x2(), b.as_i64x2())) }
400}
401
402#[inline]
407#[target_feature(enable = "sse2")]
408#[cfg_attr(test, assert_instr(psubsb))]
409#[stable(feature = "simd_x86", since = "1.27.0")]
410#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
411pub const fn _mm_subs_epi8(a: __m128i, b: __m128i) -> __m128i {
412 unsafe { transmute(simd_saturating_sub(a.as_i8x16(), b.as_i8x16())) }
413}
414
415#[inline]
420#[target_feature(enable = "sse2")]
421#[cfg_attr(test, assert_instr(psubsw))]
422#[stable(feature = "simd_x86", since = "1.27.0")]
423#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
424pub const fn _mm_subs_epi16(a: __m128i, b: __m128i) -> __m128i {
425 unsafe { transmute(simd_saturating_sub(a.as_i16x8(), b.as_i16x8())) }
426}
427
428#[inline]
433#[target_feature(enable = "sse2")]
434#[cfg_attr(test, assert_instr(psubusb))]
435#[stable(feature = "simd_x86", since = "1.27.0")]
436#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
437pub const fn _mm_subs_epu8(a: __m128i, b: __m128i) -> __m128i {
438 unsafe { transmute(simd_saturating_sub(a.as_u8x16(), b.as_u8x16())) }
439}
440
441#[inline]
446#[target_feature(enable = "sse2")]
447#[cfg_attr(test, assert_instr(psubusw))]
448#[stable(feature = "simd_x86", since = "1.27.0")]
449#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
450pub const fn _mm_subs_epu16(a: __m128i, b: __m128i) -> __m128i {
451 unsafe { transmute(simd_saturating_sub(a.as_u16x8(), b.as_u16x8())) }
452}
453
454#[inline]
458#[target_feature(enable = "sse2")]
459#[cfg_attr(test, assert_instr(pslldq, IMM8 = 1))]
460#[rustc_legacy_const_generics(1)]
461#[stable(feature = "simd_x86", since = "1.27.0")]
462#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
463pub const fn _mm_slli_si128<const IMM8: i32>(a: __m128i) -> __m128i {
464 static_assert_uimm_bits!(IMM8, 8);
465 unsafe { _mm_slli_si128_impl::<IMM8>(a) }
466}
467
468#[inline]
471#[target_feature(enable = "sse2")]
472#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
473const unsafe fn _mm_slli_si128_impl<const IMM8: i32>(a: __m128i) -> __m128i {
474 const fn mask(shift: i32, i: u32) -> u32 {
475 let shift = shift as u32 & 0xff;
476 if shift > 15 { i } else { 16 - shift + i }
477 }
478 transmute::<i8x16, _>(simd_shuffle!(
479 i8x16::ZERO,
480 a.as_i8x16(),
481 [
482 mask(IMM8, 0),
483 mask(IMM8, 1),
484 mask(IMM8, 2),
485 mask(IMM8, 3),
486 mask(IMM8, 4),
487 mask(IMM8, 5),
488 mask(IMM8, 6),
489 mask(IMM8, 7),
490 mask(IMM8, 8),
491 mask(IMM8, 9),
492 mask(IMM8, 10),
493 mask(IMM8, 11),
494 mask(IMM8, 12),
495 mask(IMM8, 13),
496 mask(IMM8, 14),
497 mask(IMM8, 15),
498 ],
499 ))
500}
501
502#[inline]
506#[target_feature(enable = "sse2")]
507#[cfg_attr(test, assert_instr(pslldq, IMM8 = 1))]
508#[rustc_legacy_const_generics(1)]
509#[stable(feature = "simd_x86", since = "1.27.0")]
510#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
511pub const fn _mm_bslli_si128<const IMM8: i32>(a: __m128i) -> __m128i {
512 unsafe {
513 static_assert_uimm_bits!(IMM8, 8);
514 _mm_slli_si128_impl::<IMM8>(a)
515 }
516}
517
518#[inline]
522#[target_feature(enable = "sse2")]
523#[cfg_attr(test, assert_instr(psrldq, IMM8 = 1))]
524#[rustc_legacy_const_generics(1)]
525#[stable(feature = "simd_x86", since = "1.27.0")]
526#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
527pub const fn _mm_bsrli_si128<const IMM8: i32>(a: __m128i) -> __m128i {
528 unsafe {
529 static_assert_uimm_bits!(IMM8, 8);
530 _mm_srli_si128_impl::<IMM8>(a)
531 }
532}
533
534#[inline]
538#[target_feature(enable = "sse2")]
539#[cfg_attr(test, assert_instr(psllw, IMM8 = 7))]
540#[rustc_legacy_const_generics(1)]
541#[stable(feature = "simd_x86", since = "1.27.0")]
542#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
543pub const fn _mm_slli_epi16<const IMM8: i32>(a: __m128i) -> __m128i {
544 static_assert_uimm_bits!(IMM8, 8);
545 unsafe {
546 if IMM8 >= 16 {
547 _mm_setzero_si128()
548 } else {
549 transmute(simd_shl(a.as_u16x8(), u16x8::splat(IMM8 as u16)))
550 }
551 }
552}
553
554#[inline]
559#[target_feature(enable = "sse2")]
560#[cfg_attr(test, assert_instr(psllw))]
561#[stable(feature = "simd_x86", since = "1.27.0")]
562pub fn _mm_sll_epi16(a: __m128i, count: __m128i) -> __m128i {
563 unsafe { transmute(psllw(a.as_i16x8(), count.as_i16x8())) }
564}
565
566#[inline]
570#[target_feature(enable = "sse2")]
571#[cfg_attr(test, assert_instr(pslld, IMM8 = 7))]
572#[rustc_legacy_const_generics(1)]
573#[stable(feature = "simd_x86", since = "1.27.0")]
574#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
575pub const fn _mm_slli_epi32<const IMM8: i32>(a: __m128i) -> __m128i {
576 static_assert_uimm_bits!(IMM8, 8);
577 unsafe {
578 if IMM8 >= 32 {
579 _mm_setzero_si128()
580 } else {
581 transmute(simd_shl(a.as_u32x4(), u32x4::splat(IMM8 as u32)))
582 }
583 }
584}
585
586#[inline]
591#[target_feature(enable = "sse2")]
592#[cfg_attr(test, assert_instr(pslld))]
593#[stable(feature = "simd_x86", since = "1.27.0")]
594pub fn _mm_sll_epi32(a: __m128i, count: __m128i) -> __m128i {
595 unsafe { transmute(pslld(a.as_i32x4(), count.as_i32x4())) }
596}
597
598#[inline]
602#[target_feature(enable = "sse2")]
603#[cfg_attr(test, assert_instr(psllq, IMM8 = 7))]
604#[rustc_legacy_const_generics(1)]
605#[stable(feature = "simd_x86", since = "1.27.0")]
606#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
607pub const fn _mm_slli_epi64<const IMM8: i32>(a: __m128i) -> __m128i {
608 static_assert_uimm_bits!(IMM8, 8);
609 unsafe {
610 if IMM8 >= 64 {
611 _mm_setzero_si128()
612 } else {
613 transmute(simd_shl(a.as_u64x2(), u64x2::splat(IMM8 as u64)))
614 }
615 }
616}
617
618#[inline]
623#[target_feature(enable = "sse2")]
624#[cfg_attr(test, assert_instr(psllq))]
625#[stable(feature = "simd_x86", since = "1.27.0")]
626pub fn _mm_sll_epi64(a: __m128i, count: __m128i) -> __m128i {
627 unsafe { transmute(psllq(a.as_i64x2(), count.as_i64x2())) }
628}
629
630#[inline]
635#[target_feature(enable = "sse2")]
636#[cfg_attr(test, assert_instr(psraw, IMM8 = 1))]
637#[rustc_legacy_const_generics(1)]
638#[stable(feature = "simd_x86", since = "1.27.0")]
639#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
640pub const fn _mm_srai_epi16<const IMM8: i32>(a: __m128i) -> __m128i {
641 static_assert_uimm_bits!(IMM8, 8);
642 unsafe { transmute(simd_shr(a.as_i16x8(), i16x8::splat(IMM8.min(15) as i16))) }
643}
644
645#[inline]
650#[target_feature(enable = "sse2")]
651#[cfg_attr(test, assert_instr(psraw))]
652#[stable(feature = "simd_x86", since = "1.27.0")]
653pub fn _mm_sra_epi16(a: __m128i, count: __m128i) -> __m128i {
654 unsafe { transmute(psraw(a.as_i16x8(), count.as_i16x8())) }
655}
656
657#[inline]
662#[target_feature(enable = "sse2")]
663#[cfg_attr(test, assert_instr(psrad, IMM8 = 1))]
664#[rustc_legacy_const_generics(1)]
665#[stable(feature = "simd_x86", since = "1.27.0")]
666#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
667pub const fn _mm_srai_epi32<const IMM8: i32>(a: __m128i) -> __m128i {
668 static_assert_uimm_bits!(IMM8, 8);
669 unsafe { transmute(simd_shr(a.as_i32x4(), i32x4::splat(IMM8.min(31)))) }
670}
671
672#[inline]
677#[target_feature(enable = "sse2")]
678#[cfg_attr(test, assert_instr(psrad))]
679#[stable(feature = "simd_x86", since = "1.27.0")]
680pub fn _mm_sra_epi32(a: __m128i, count: __m128i) -> __m128i {
681 unsafe { transmute(psrad(a.as_i32x4(), count.as_i32x4())) }
682}
683
684#[inline]
688#[target_feature(enable = "sse2")]
689#[cfg_attr(test, assert_instr(psrldq, IMM8 = 1))]
690#[rustc_legacy_const_generics(1)]
691#[stable(feature = "simd_x86", since = "1.27.0")]
692#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
693pub const fn _mm_srli_si128<const IMM8: i32>(a: __m128i) -> __m128i {
694 static_assert_uimm_bits!(IMM8, 8);
695 unsafe { _mm_srli_si128_impl::<IMM8>(a) }
696}
697
698#[inline]
701#[target_feature(enable = "sse2")]
702#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
703const unsafe fn _mm_srli_si128_impl<const IMM8: i32>(a: __m128i) -> __m128i {
704 const fn mask(shift: i32, i: u32) -> u32 {
705 if (shift as u32) > 15 {
706 i + 16
707 } else {
708 i + (shift as u32)
709 }
710 }
711 let x: i8x16 = simd_shuffle!(
712 a.as_i8x16(),
713 i8x16::ZERO,
714 [
715 mask(IMM8, 0),
716 mask(IMM8, 1),
717 mask(IMM8, 2),
718 mask(IMM8, 3),
719 mask(IMM8, 4),
720 mask(IMM8, 5),
721 mask(IMM8, 6),
722 mask(IMM8, 7),
723 mask(IMM8, 8),
724 mask(IMM8, 9),
725 mask(IMM8, 10),
726 mask(IMM8, 11),
727 mask(IMM8, 12),
728 mask(IMM8, 13),
729 mask(IMM8, 14),
730 mask(IMM8, 15),
731 ],
732 );
733 transmute(x)
734}
735
736#[inline]
741#[target_feature(enable = "sse2")]
742#[cfg_attr(test, assert_instr(psrlw, IMM8 = 1))]
743#[rustc_legacy_const_generics(1)]
744#[stable(feature = "simd_x86", since = "1.27.0")]
745#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
746pub const fn _mm_srli_epi16<const IMM8: i32>(a: __m128i) -> __m128i {
747 static_assert_uimm_bits!(IMM8, 8);
748 unsafe {
749 if IMM8 >= 16 {
750 _mm_setzero_si128()
751 } else {
752 transmute(simd_shr(a.as_u16x8(), u16x8::splat(IMM8 as u16)))
753 }
754 }
755}
756
757#[inline]
762#[target_feature(enable = "sse2")]
763#[cfg_attr(test, assert_instr(psrlw))]
764#[stable(feature = "simd_x86", since = "1.27.0")]
765pub fn _mm_srl_epi16(a: __m128i, count: __m128i) -> __m128i {
766 unsafe { transmute(psrlw(a.as_i16x8(), count.as_i16x8())) }
767}
768
769#[inline]
774#[target_feature(enable = "sse2")]
775#[cfg_attr(test, assert_instr(psrld, IMM8 = 8))]
776#[rustc_legacy_const_generics(1)]
777#[stable(feature = "simd_x86", since = "1.27.0")]
778#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
779pub const fn _mm_srli_epi32<const IMM8: i32>(a: __m128i) -> __m128i {
780 static_assert_uimm_bits!(IMM8, 8);
781 unsafe {
782 if IMM8 >= 32 {
783 _mm_setzero_si128()
784 } else {
785 transmute(simd_shr(a.as_u32x4(), u32x4::splat(IMM8 as u32)))
786 }
787 }
788}
789
790#[inline]
795#[target_feature(enable = "sse2")]
796#[cfg_attr(test, assert_instr(psrld))]
797#[stable(feature = "simd_x86", since = "1.27.0")]
798pub fn _mm_srl_epi32(a: __m128i, count: __m128i) -> __m128i {
799 unsafe { transmute(psrld(a.as_i32x4(), count.as_i32x4())) }
800}
801
802#[inline]
807#[target_feature(enable = "sse2")]
808#[cfg_attr(test, assert_instr(psrlq, IMM8 = 1))]
809#[rustc_legacy_const_generics(1)]
810#[stable(feature = "simd_x86", since = "1.27.0")]
811#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
812pub const fn _mm_srli_epi64<const IMM8: i32>(a: __m128i) -> __m128i {
813 static_assert_uimm_bits!(IMM8, 8);
814 unsafe {
815 if IMM8 >= 64 {
816 _mm_setzero_si128()
817 } else {
818 transmute(simd_shr(a.as_u64x2(), u64x2::splat(IMM8 as u64)))
819 }
820 }
821}
822
823#[inline]
828#[target_feature(enable = "sse2")]
829#[cfg_attr(test, assert_instr(psrlq))]
830#[stable(feature = "simd_x86", since = "1.27.0")]
831pub fn _mm_srl_epi64(a: __m128i, count: __m128i) -> __m128i {
832 unsafe { transmute(psrlq(a.as_i64x2(), count.as_i64x2())) }
833}
834
835#[inline]
840#[target_feature(enable = "sse2")]
841#[cfg_attr(test, assert_instr(andps))]
842#[stable(feature = "simd_x86", since = "1.27.0")]
843#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
844pub const fn _mm_and_si128(a: __m128i, b: __m128i) -> __m128i {
845 unsafe { simd_and(a, b) }
846}
847
848#[inline]
853#[target_feature(enable = "sse2")]
854#[cfg_attr(test, assert_instr(andnps))]
855#[stable(feature = "simd_x86", since = "1.27.0")]
856#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
857pub const fn _mm_andnot_si128(a: __m128i, b: __m128i) -> __m128i {
858 unsafe { simd_and(simd_xor(_mm_set1_epi8(-1), a), b) }
859}
860
861#[ferrocene::prevalidated]
866#[inline]
867#[target_feature(enable = "sse2")]
868#[cfg_attr(test, assert_instr(orps))]
869#[stable(feature = "simd_x86", since = "1.27.0")]
870#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
871pub const fn _mm_or_si128(a: __m128i, b: __m128i) -> __m128i {
872 unsafe { simd_or(a, b) }
873}
874
875#[inline]
880#[target_feature(enable = "sse2")]
881#[cfg_attr(test, assert_instr(xorps))]
882#[stable(feature = "simd_x86", since = "1.27.0")]
883#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
884pub const fn _mm_xor_si128(a: __m128i, b: __m128i) -> __m128i {
885 unsafe { simd_xor(a, b) }
886}
887
888#[inline]
892#[target_feature(enable = "sse2")]
893#[cfg_attr(test, assert_instr(pcmpeqb))]
894#[stable(feature = "simd_x86", since = "1.27.0")]
895#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
896pub const fn _mm_cmpeq_epi8(a: __m128i, b: __m128i) -> __m128i {
897 unsafe { transmute::<i8x16, _>(simd_eq(a.as_i8x16(), b.as_i8x16())) }
898}
899
900#[inline]
904#[target_feature(enable = "sse2")]
905#[cfg_attr(test, assert_instr(pcmpeqw))]
906#[stable(feature = "simd_x86", since = "1.27.0")]
907#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
908pub const fn _mm_cmpeq_epi16(a: __m128i, b: __m128i) -> __m128i {
909 unsafe { transmute::<i16x8, _>(simd_eq(a.as_i16x8(), b.as_i16x8())) }
910}
911
912#[inline]
916#[target_feature(enable = "sse2")]
917#[cfg_attr(test, assert_instr(pcmpeqd))]
918#[stable(feature = "simd_x86", since = "1.27.0")]
919#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
920pub const fn _mm_cmpeq_epi32(a: __m128i, b: __m128i) -> __m128i {
921 unsafe { transmute::<i32x4, _>(simd_eq(a.as_i32x4(), b.as_i32x4())) }
922}
923
924#[inline]
928#[target_feature(enable = "sse2")]
929#[cfg_attr(test, assert_instr(pcmpgtb))]
930#[stable(feature = "simd_x86", since = "1.27.0")]
931#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
932pub const fn _mm_cmpgt_epi8(a: __m128i, b: __m128i) -> __m128i {
933 unsafe { transmute::<i8x16, _>(simd_gt(a.as_i8x16(), b.as_i8x16())) }
934}
935
936#[inline]
940#[target_feature(enable = "sse2")]
941#[cfg_attr(test, assert_instr(pcmpgtw))]
942#[stable(feature = "simd_x86", since = "1.27.0")]
943#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
944pub const fn _mm_cmpgt_epi16(a: __m128i, b: __m128i) -> __m128i {
945 unsafe { transmute::<i16x8, _>(simd_gt(a.as_i16x8(), b.as_i16x8())) }
946}
947
948#[inline]
952#[target_feature(enable = "sse2")]
953#[cfg_attr(test, assert_instr(pcmpgtd))]
954#[stable(feature = "simd_x86", since = "1.27.0")]
955#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
956pub const fn _mm_cmpgt_epi32(a: __m128i, b: __m128i) -> __m128i {
957 unsafe { transmute::<i32x4, _>(simd_gt(a.as_i32x4(), b.as_i32x4())) }
958}
959
960#[inline]
964#[target_feature(enable = "sse2")]
965#[cfg_attr(test, assert_instr(pcmpgtb))]
966#[stable(feature = "simd_x86", since = "1.27.0")]
967#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
968pub const fn _mm_cmplt_epi8(a: __m128i, b: __m128i) -> __m128i {
969 unsafe { transmute::<i8x16, _>(simd_lt(a.as_i8x16(), b.as_i8x16())) }
970}
971
972#[inline]
976#[target_feature(enable = "sse2")]
977#[cfg_attr(test, assert_instr(pcmpgtw))]
978#[stable(feature = "simd_x86", since = "1.27.0")]
979#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
980pub const fn _mm_cmplt_epi16(a: __m128i, b: __m128i) -> __m128i {
981 unsafe { transmute::<i16x8, _>(simd_lt(a.as_i16x8(), b.as_i16x8())) }
982}
983
984#[inline]
988#[target_feature(enable = "sse2")]
989#[cfg_attr(test, assert_instr(pcmpgtd))]
990#[stable(feature = "simd_x86", since = "1.27.0")]
991#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
992pub const fn _mm_cmplt_epi32(a: __m128i, b: __m128i) -> __m128i {
993 unsafe { transmute::<i32x4, _>(simd_lt(a.as_i32x4(), b.as_i32x4())) }
994}
995
996#[inline]
1001#[target_feature(enable = "sse2")]
1002#[cfg_attr(test, assert_instr(cvtdq2pd))]
1003#[stable(feature = "simd_x86", since = "1.27.0")]
1004#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1005pub const fn _mm_cvtepi32_pd(a: __m128i) -> __m128d {
1006 unsafe {
1007 let a = a.as_i32x4();
1008 simd_cast::<i32x2, __m128d>(simd_shuffle!(a, a, [0, 1]))
1009 }
1010}
1011
1012#[inline]
1017#[target_feature(enable = "sse2")]
1018#[cfg_attr(test, assert_instr(cvtsi2sd))]
1019#[stable(feature = "simd_x86", since = "1.27.0")]
1020#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1021pub const fn _mm_cvtsi32_sd(a: __m128d, b: i32) -> __m128d {
1022 unsafe { simd_insert!(a, 0, b as f64) }
1023}
1024
1025#[inline]
1030#[target_feature(enable = "sse2")]
1031#[cfg_attr(test, assert_instr(cvtdq2ps))]
1032#[stable(feature = "simd_x86", since = "1.27.0")]
1033#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1034pub const fn _mm_cvtepi32_ps(a: __m128i) -> __m128 {
1035 unsafe { transmute(simd_cast::<_, f32x4>(a.as_i32x4())) }
1036}
1037
1038#[inline]
1043#[target_feature(enable = "sse2")]
1044#[cfg_attr(test, assert_instr(cvtps2dq))]
1045#[stable(feature = "simd_x86", since = "1.27.0")]
1046pub fn _mm_cvtps_epi32(a: __m128) -> __m128i {
1047 unsafe { transmute(cvtps2dq(a)) }
1048}
1049
1050#[inline]
1055#[target_feature(enable = "sse2")]
1056#[stable(feature = "simd_x86", since = "1.27.0")]
1057#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1058pub const fn _mm_cvtsi32_si128(a: i32) -> __m128i {
1059 unsafe { transmute(i32x4::new(a, 0, 0, 0)) }
1060}
1061
1062#[inline]
1066#[target_feature(enable = "sse2")]
1067#[stable(feature = "simd_x86", since = "1.27.0")]
1068#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1069pub const fn _mm_cvtsi128_si32(a: __m128i) -> i32 {
1070 unsafe { simd_extract!(a.as_i32x4(), 0) }
1071}
1072
1073#[inline]
1078#[target_feature(enable = "sse2")]
1079#[stable(feature = "simd_x86", since = "1.27.0")]
1081#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1082pub const fn _mm_set_epi64x(e1: i64, e0: i64) -> __m128i {
1083 unsafe { transmute(i64x2::new(e0, e1)) }
1084}
1085
1086#[inline]
1090#[target_feature(enable = "sse2")]
1091#[stable(feature = "simd_x86", since = "1.27.0")]
1093#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1094pub const fn _mm_set_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i {
1095 unsafe { transmute(i32x4::new(e0, e1, e2, e3)) }
1096}
1097
1098#[inline]
1102#[target_feature(enable = "sse2")]
1103#[stable(feature = "simd_x86", since = "1.27.0")]
1105#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1106pub const fn _mm_set_epi16(
1107 e7: i16,
1108 e6: i16,
1109 e5: i16,
1110 e4: i16,
1111 e3: i16,
1112 e2: i16,
1113 e1: i16,
1114 e0: i16,
1115) -> __m128i {
1116 unsafe { transmute(i16x8::new(e0, e1, e2, e3, e4, e5, e6, e7)) }
1117}
1118
1119#[inline]
1123#[target_feature(enable = "sse2")]
1124#[stable(feature = "simd_x86", since = "1.27.0")]
1126#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1127pub const fn _mm_set_epi8(
1128 e15: i8,
1129 e14: i8,
1130 e13: i8,
1131 e12: i8,
1132 e11: i8,
1133 e10: i8,
1134 e9: i8,
1135 e8: i8,
1136 e7: i8,
1137 e6: i8,
1138 e5: i8,
1139 e4: i8,
1140 e3: i8,
1141 e2: i8,
1142 e1: i8,
1143 e0: i8,
1144) -> __m128i {
1145 unsafe {
1146 #[rustfmt::skip]
1147 transmute(i8x16::new(
1148 e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15,
1149 ))
1150 }
1151}
1152
1153#[inline]
1157#[target_feature(enable = "sse2")]
1158#[stable(feature = "simd_x86", since = "1.27.0")]
1160#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1161pub const fn _mm_set1_epi64x(a: i64) -> __m128i {
1162 i64x2::splat(a).as_m128i()
1163}
1164
1165#[inline]
1169#[target_feature(enable = "sse2")]
1170#[stable(feature = "simd_x86", since = "1.27.0")]
1172#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1173pub const fn _mm_set1_epi32(a: i32) -> __m128i {
1174 i32x4::splat(a).as_m128i()
1175}
1176
1177#[inline]
1181#[target_feature(enable = "sse2")]
1182#[stable(feature = "simd_x86", since = "1.27.0")]
1184#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1185pub const fn _mm_set1_epi16(a: i16) -> __m128i {
1186 i16x8::splat(a).as_m128i()
1187}
1188
1189#[inline]
1193#[target_feature(enable = "sse2")]
1194#[stable(feature = "simd_x86", since = "1.27.0")]
1196#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1197pub const fn _mm_set1_epi8(a: i8) -> __m128i {
1198 i8x16::splat(a).as_m128i()
1199}
1200
1201#[inline]
1205#[target_feature(enable = "sse2")]
1206#[stable(feature = "simd_x86", since = "1.27.0")]
1208#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1209pub const fn _mm_setr_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i {
1210 _mm_set_epi32(e0, e1, e2, e3)
1211}
1212
1213#[inline]
1217#[target_feature(enable = "sse2")]
1218#[stable(feature = "simd_x86", since = "1.27.0")]
1220#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1221pub const fn _mm_setr_epi16(
1222 e7: i16,
1223 e6: i16,
1224 e5: i16,
1225 e4: i16,
1226 e3: i16,
1227 e2: i16,
1228 e1: i16,
1229 e0: i16,
1230) -> __m128i {
1231 _mm_set_epi16(e0, e1, e2, e3, e4, e5, e6, e7)
1232}
1233
1234#[inline]
1238#[target_feature(enable = "sse2")]
1239#[stable(feature = "simd_x86", since = "1.27.0")]
1241#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1242pub const fn _mm_setr_epi8(
1243 e15: i8,
1244 e14: i8,
1245 e13: i8,
1246 e12: i8,
1247 e11: i8,
1248 e10: i8,
1249 e9: i8,
1250 e8: i8,
1251 e7: i8,
1252 e6: i8,
1253 e5: i8,
1254 e4: i8,
1255 e3: i8,
1256 e2: i8,
1257 e1: i8,
1258 e0: i8,
1259) -> __m128i {
1260 #[rustfmt::skip]
1261 _mm_set_epi8(
1262 e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15,
1263 )
1264}
1265
1266#[inline]
1270#[target_feature(enable = "sse2")]
1271#[cfg_attr(test, assert_instr(xorps))]
1272#[stable(feature = "simd_x86", since = "1.27.0")]
1273#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1274pub const fn _mm_setzero_si128() -> __m128i {
1275 const { unsafe { mem::zeroed() } }
1276}
1277
1278#[inline]
1282#[target_feature(enable = "sse2")]
1283#[stable(feature = "simd_x86", since = "1.27.0")]
1284#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1285pub const unsafe fn _mm_loadl_epi64(mem_addr: *const __m128i) -> __m128i {
1286 _mm_set_epi64x(0, ptr::read_unaligned(mem_addr as *const i64))
1287}
1288
1289#[inline]
1295#[target_feature(enable = "sse2")]
1296#[cfg_attr(
1297 all(test, not(all(target_arch = "x86", target_env = "msvc"))),
1298 assert_instr(movaps)
1299)]
1300#[stable(feature = "simd_x86", since = "1.27.0")]
1301#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1302pub const unsafe fn _mm_load_si128(mem_addr: *const __m128i) -> __m128i {
1303 *mem_addr
1304}
1305
1306#[ferrocene::prevalidated]
1312#[inline]
1313#[target_feature(enable = "sse2")]
1314#[cfg_attr(test, assert_instr(movups))]
1315#[stable(feature = "simd_x86", since = "1.27.0")]
1316#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1317pub const unsafe fn _mm_loadu_si128(mem_addr: *const __m128i) -> __m128i {
1318 let mut dst: __m128i = _mm_undefined_si128();
1319 ptr::copy_nonoverlapping(
1320 mem_addr as *const u8,
1321 ptr::addr_of_mut!(dst) as *mut u8,
1322 mem::size_of::<__m128i>(),
1323 );
1324 dst
1325}
1326
1327#[inline]
1348#[target_feature(enable = "sse2")]
1349#[cfg_attr(test, assert_instr(maskmovdqu))]
1350#[stable(feature = "simd_x86", since = "1.27.0")]
1351pub unsafe fn _mm_maskmoveu_si128(a: __m128i, mask: __m128i, mem_addr: *mut i8) {
1352 maskmovdqu(a.as_i8x16(), mask.as_i8x16(), mem_addr)
1353}
1354
1355#[inline]
1361#[target_feature(enable = "sse2")]
1362#[cfg_attr(
1363 all(test, not(all(target_arch = "x86", target_env = "msvc"))),
1364 assert_instr(movaps)
1365)]
1366#[stable(feature = "simd_x86", since = "1.27.0")]
1367#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1368pub const unsafe fn _mm_store_si128(mem_addr: *mut __m128i, a: __m128i) {
1369 *mem_addr = a;
1370}
1371
1372#[inline]
1378#[target_feature(enable = "sse2")]
1379#[cfg_attr(test, assert_instr(movups))] #[stable(feature = "simd_x86", since = "1.27.0")]
1381#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1382pub const unsafe fn _mm_storeu_si128(mem_addr: *mut __m128i, a: __m128i) {
1383 mem_addr.write_unaligned(a);
1384}
1385
1386#[inline]
1392#[target_feature(enable = "sse2")]
1393#[stable(feature = "simd_x86", since = "1.27.0")]
1394#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1395pub const unsafe fn _mm_storel_epi64(mem_addr: *mut __m128i, a: __m128i) {
1396 ptr::copy_nonoverlapping(ptr::addr_of!(a) as *const u8, mem_addr as *mut u8, 8);
1397}
1398
1399#[inline]
1414#[target_feature(enable = "sse2")]
1415#[cfg_attr(test, assert_instr(movntdq))]
1416#[stable(feature = "simd_x86", since = "1.27.0")]
1417pub unsafe fn _mm_stream_si128(mem_addr: *mut __m128i, a: __m128i) {
1418 crate::arch::asm!(
1420 vps!("movntdq", ",{a}"),
1421 p = in(reg) mem_addr,
1422 a = in(xmm_reg) a,
1423 options(nostack, preserves_flags),
1424 );
1425}
1426
1427#[inline]
1442#[target_feature(enable = "sse2")]
1443#[cfg_attr(test, assert_instr(movnti))]
1444#[stable(feature = "simd_x86", since = "1.27.0")]
1445pub unsafe fn _mm_stream_si32(mem_addr: *mut i32, a: i32) {
1446 crate::arch::asm!(
1448 vps!("movnti", ",{a:e}"), p = in(reg) mem_addr,
1450 a = in(reg) a,
1451 options(nostack, preserves_flags),
1452 );
1453}
1454
1455#[inline]
1460#[target_feature(enable = "sse2")]
1461#[cfg_attr(all(test, target_arch = "x86_64"), assert_instr(movq))]
1463#[stable(feature = "simd_x86", since = "1.27.0")]
1464#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1465pub const fn _mm_move_epi64(a: __m128i) -> __m128i {
1466 unsafe {
1467 let r: i64x2 = simd_shuffle!(a.as_i64x2(), i64x2::ZERO, [0, 2]);
1468 transmute(r)
1469 }
1470}
1471
1472#[inline]
1477#[target_feature(enable = "sse2")]
1478#[cfg_attr(test, assert_instr(packsswb, limit(5), not(pmin), not(pmax)))]
1479#[stable(feature = "simd_x86", since = "1.27.0")]
1480pub fn _mm_packs_epi16(a: __m128i, b: __m128i) -> __m128i {
1481 unsafe { transmute(packsswb(a.as_i16x8(), b.as_i16x8())) }
1482}
1483
1484#[inline]
1489#[target_feature(enable = "sse2")]
1490#[cfg_attr(test, assert_instr(packssdw, limit(5), not(pmin), not(pmax)))]
1491#[stable(feature = "simd_x86", since = "1.27.0")]
1492pub fn _mm_packs_epi32(a: __m128i, b: __m128i) -> __m128i {
1493 unsafe { transmute(packssdw(a.as_i32x4(), b.as_i32x4())) }
1494}
1495
1496#[inline]
1501#[target_feature(enable = "sse2")]
1502#[cfg_attr(test, assert_instr(packuswb, limit(5), not(pmin), not(pmax)))]
1503#[stable(feature = "simd_x86", since = "1.27.0")]
1504pub fn _mm_packus_epi16(a: __m128i, b: __m128i) -> __m128i {
1505 unsafe { transmute(packuswb(a.as_i16x8(), b.as_i16x8())) }
1506}
1507
1508#[inline]
1512#[target_feature(enable = "sse2")]
1513#[cfg_attr(test, assert_instr(pextrw, IMM8 = 7))]
1514#[rustc_legacy_const_generics(1)]
1515#[stable(feature = "simd_x86", since = "1.27.0")]
1516#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1517pub const fn _mm_extract_epi16<const IMM8: i32>(a: __m128i) -> i32 {
1518 static_assert_uimm_bits!(IMM8, 3);
1519 unsafe { simd_extract!(a.as_u16x8(), IMM8 as u32, u16) as i32 }
1520}
1521
1522#[inline]
1526#[target_feature(enable = "sse2")]
1527#[cfg_attr(test, assert_instr(pinsrw, IMM8 = 7))]
1528#[rustc_legacy_const_generics(2)]
1529#[stable(feature = "simd_x86", since = "1.27.0")]
1530#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1531pub const fn _mm_insert_epi16<const IMM8: i32>(a: __m128i, i: i32) -> __m128i {
1532 static_assert_uimm_bits!(IMM8, 3);
1533 unsafe { transmute(simd_insert!(a.as_i16x8(), IMM8 as u32, i as i16)) }
1534}
1535
1536#[ferrocene::prevalidated]
1540#[inline]
1541#[target_feature(enable = "sse2")]
1542#[cfg_attr(test, assert_instr(pmovmskb))]
1543#[stable(feature = "simd_x86", since = "1.27.0")]
1544#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1545pub const fn _mm_movemask_epi8(a: __m128i) -> i32 {
1546 unsafe {
1547 let z = i8x16::ZERO;
1548 let m: i8x16 = simd_lt(a.as_i8x16(), z);
1549 simd_bitmask::<_, u16>(m) as u32 as i32
1550 }
1551}
1552
1553#[inline]
1557#[target_feature(enable = "sse2")]
1558#[cfg_attr(test, assert_instr(pshufd, IMM8 = 9))]
1559#[rustc_legacy_const_generics(1)]
1560#[stable(feature = "simd_x86", since = "1.27.0")]
1561#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1562pub const fn _mm_shuffle_epi32<const IMM8: i32>(a: __m128i) -> __m128i {
1563 static_assert_uimm_bits!(IMM8, 8);
1564 unsafe {
1565 let a = a.as_i32x4();
1566 let x: i32x4 = simd_shuffle!(
1567 a,
1568 a,
1569 [
1570 IMM8 as u32 & 0b11,
1571 (IMM8 as u32 >> 2) & 0b11,
1572 (IMM8 as u32 >> 4) & 0b11,
1573 (IMM8 as u32 >> 6) & 0b11,
1574 ],
1575 );
1576 transmute(x)
1577 }
1578}
1579
1580#[inline]
1588#[target_feature(enable = "sse2")]
1589#[cfg_attr(test, assert_instr(pshufhw, IMM8 = 9))]
1590#[rustc_legacy_const_generics(1)]
1591#[stable(feature = "simd_x86", since = "1.27.0")]
1592#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1593pub const fn _mm_shufflehi_epi16<const IMM8: i32>(a: __m128i) -> __m128i {
1594 static_assert_uimm_bits!(IMM8, 8);
1595 unsafe {
1596 let a = a.as_i16x8();
1597 let x: i16x8 = simd_shuffle!(
1598 a,
1599 a,
1600 [
1601 0,
1602 1,
1603 2,
1604 3,
1605 (IMM8 as u32 & 0b11) + 4,
1606 ((IMM8 as u32 >> 2) & 0b11) + 4,
1607 ((IMM8 as u32 >> 4) & 0b11) + 4,
1608 ((IMM8 as u32 >> 6) & 0b11) + 4,
1609 ],
1610 );
1611 transmute(x)
1612 }
1613}
1614
1615#[inline]
1623#[target_feature(enable = "sse2")]
1624#[cfg_attr(test, assert_instr(pshuflw, IMM8 = 9))]
1625#[rustc_legacy_const_generics(1)]
1626#[stable(feature = "simd_x86", since = "1.27.0")]
1627#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1628pub const fn _mm_shufflelo_epi16<const IMM8: i32>(a: __m128i) -> __m128i {
1629 static_assert_uimm_bits!(IMM8, 8);
1630 unsafe {
1631 let a = a.as_i16x8();
1632 let x: i16x8 = simd_shuffle!(
1633 a,
1634 a,
1635 [
1636 IMM8 as u32 & 0b11,
1637 (IMM8 as u32 >> 2) & 0b11,
1638 (IMM8 as u32 >> 4) & 0b11,
1639 (IMM8 as u32 >> 6) & 0b11,
1640 4,
1641 5,
1642 6,
1643 7,
1644 ],
1645 );
1646 transmute(x)
1647 }
1648}
1649
1650#[inline]
1654#[target_feature(enable = "sse2")]
1655#[cfg_attr(test, assert_instr(punpckhbw))]
1656#[stable(feature = "simd_x86", since = "1.27.0")]
1657#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1658pub const fn _mm_unpackhi_epi8(a: __m128i, b: __m128i) -> __m128i {
1659 unsafe {
1660 transmute::<i8x16, _>(simd_shuffle!(
1661 a.as_i8x16(),
1662 b.as_i8x16(),
1663 [8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31],
1664 ))
1665 }
1666}
1667
1668#[inline]
1672#[target_feature(enable = "sse2")]
1673#[cfg_attr(test, assert_instr(punpckhwd))]
1674#[stable(feature = "simd_x86", since = "1.27.0")]
1675#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1676pub const fn _mm_unpackhi_epi16(a: __m128i, b: __m128i) -> __m128i {
1677 unsafe {
1678 let x = simd_shuffle!(a.as_i16x8(), b.as_i16x8(), [4, 12, 5, 13, 6, 14, 7, 15]);
1679 transmute::<i16x8, _>(x)
1680 }
1681}
1682
1683#[inline]
1687#[target_feature(enable = "sse2")]
1688#[cfg_attr(test, assert_instr(unpckhps))]
1689#[stable(feature = "simd_x86", since = "1.27.0")]
1690#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1691pub const fn _mm_unpackhi_epi32(a: __m128i, b: __m128i) -> __m128i {
1692 unsafe { transmute::<i32x4, _>(simd_shuffle!(a.as_i32x4(), b.as_i32x4(), [2, 6, 3, 7])) }
1693}
1694
1695#[inline]
1699#[target_feature(enable = "sse2")]
1700#[cfg_attr(test, assert_instr(unpckhpd))]
1701#[stable(feature = "simd_x86", since = "1.27.0")]
1702#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1703pub const fn _mm_unpackhi_epi64(a: __m128i, b: __m128i) -> __m128i {
1704 unsafe { transmute::<i64x2, _>(simd_shuffle!(a.as_i64x2(), b.as_i64x2(), [1, 3])) }
1705}
1706
1707#[inline]
1711#[target_feature(enable = "sse2")]
1712#[cfg_attr(test, assert_instr(punpcklbw))]
1713#[stable(feature = "simd_x86", since = "1.27.0")]
1714#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1715pub const fn _mm_unpacklo_epi8(a: __m128i, b: __m128i) -> __m128i {
1716 unsafe {
1717 transmute::<i8x16, _>(simd_shuffle!(
1718 a.as_i8x16(),
1719 b.as_i8x16(),
1720 [0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23],
1721 ))
1722 }
1723}
1724
1725#[inline]
1729#[target_feature(enable = "sse2")]
1730#[cfg_attr(test, assert_instr(punpcklwd))]
1731#[stable(feature = "simd_x86", since = "1.27.0")]
1732#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1733pub const fn _mm_unpacklo_epi16(a: __m128i, b: __m128i) -> __m128i {
1734 unsafe {
1735 let x = simd_shuffle!(a.as_i16x8(), b.as_i16x8(), [0, 8, 1, 9, 2, 10, 3, 11]);
1736 transmute::<i16x8, _>(x)
1737 }
1738}
1739
1740#[inline]
1744#[target_feature(enable = "sse2")]
1745#[cfg_attr(test, assert_instr(unpcklps))]
1746#[stable(feature = "simd_x86", since = "1.27.0")]
1747#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1748pub const fn _mm_unpacklo_epi32(a: __m128i, b: __m128i) -> __m128i {
1749 unsafe { transmute::<i32x4, _>(simd_shuffle!(a.as_i32x4(), b.as_i32x4(), [0, 4, 1, 5])) }
1750}
1751
1752#[inline]
1756#[target_feature(enable = "sse2")]
1757#[cfg_attr(test, assert_instr(movlhps))]
1758#[stable(feature = "simd_x86", since = "1.27.0")]
1759#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1760pub const fn _mm_unpacklo_epi64(a: __m128i, b: __m128i) -> __m128i {
1761 unsafe { transmute::<i64x2, _>(simd_shuffle!(a.as_i64x2(), b.as_i64x2(), [0, 2])) }
1762}
1763
1764#[inline]
1769#[target_feature(enable = "sse2")]
1770#[cfg_attr(test, assert_instr(addsd))]
1771#[stable(feature = "simd_x86", since = "1.27.0")]
1772#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1773pub const fn _mm_add_sd(a: __m128d, b: __m128d) -> __m128d {
1774 unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) + _mm_cvtsd_f64(b)) }
1775}
1776
1777#[inline]
1782#[target_feature(enable = "sse2")]
1783#[cfg_attr(test, assert_instr(addpd))]
1784#[stable(feature = "simd_x86", since = "1.27.0")]
1785#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1786pub const fn _mm_add_pd(a: __m128d, b: __m128d) -> __m128d {
1787 unsafe { simd_add(a, b) }
1788}
1789
1790#[inline]
1795#[target_feature(enable = "sse2")]
1796#[cfg_attr(test, assert_instr(divsd))]
1797#[stable(feature = "simd_x86", since = "1.27.0")]
1798#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1799pub const fn _mm_div_sd(a: __m128d, b: __m128d) -> __m128d {
1800 unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) / _mm_cvtsd_f64(b)) }
1801}
1802
1803#[inline]
1808#[target_feature(enable = "sse2")]
1809#[cfg_attr(test, assert_instr(divpd))]
1810#[stable(feature = "simd_x86", since = "1.27.0")]
1811#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1812pub const fn _mm_div_pd(a: __m128d, b: __m128d) -> __m128d {
1813 unsafe { simd_div(a, b) }
1814}
1815
1816#[inline]
1821#[target_feature(enable = "sse2")]
1822#[cfg_attr(test, assert_instr(maxsd))]
1823#[stable(feature = "simd_x86", since = "1.27.0")]
1824pub fn _mm_max_sd(a: __m128d, b: __m128d) -> __m128d {
1825 unsafe { maxsd(a, b) }
1826}
1827
1828#[inline]
1833#[target_feature(enable = "sse2")]
1834#[cfg_attr(test, assert_instr(maxpd))]
1835#[stable(feature = "simd_x86", since = "1.27.0")]
1836pub fn _mm_max_pd(a: __m128d, b: __m128d) -> __m128d {
1837 unsafe { maxpd(a, b) }
1838}
1839
1840#[inline]
1845#[target_feature(enable = "sse2")]
1846#[cfg_attr(test, assert_instr(minsd))]
1847#[stable(feature = "simd_x86", since = "1.27.0")]
1848pub fn _mm_min_sd(a: __m128d, b: __m128d) -> __m128d {
1849 unsafe { minsd(a, b) }
1850}
1851
1852#[inline]
1857#[target_feature(enable = "sse2")]
1858#[cfg_attr(test, assert_instr(minpd))]
1859#[stable(feature = "simd_x86", since = "1.27.0")]
1860pub fn _mm_min_pd(a: __m128d, b: __m128d) -> __m128d {
1861 unsafe { minpd(a, b) }
1862}
1863
1864#[inline]
1869#[target_feature(enable = "sse2")]
1870#[cfg_attr(test, assert_instr(mulsd))]
1871#[stable(feature = "simd_x86", since = "1.27.0")]
1872#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1873pub const fn _mm_mul_sd(a: __m128d, b: __m128d) -> __m128d {
1874 unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) * _mm_cvtsd_f64(b)) }
1875}
1876
1877#[inline]
1882#[target_feature(enable = "sse2")]
1883#[cfg_attr(test, assert_instr(mulpd))]
1884#[stable(feature = "simd_x86", since = "1.27.0")]
1885#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1886pub const fn _mm_mul_pd(a: __m128d, b: __m128d) -> __m128d {
1887 unsafe { simd_mul(a, b) }
1888}
1889
1890#[inline]
1895#[target_feature(enable = "sse2")]
1896#[cfg_attr(test, assert_instr(sqrtsd))]
1897#[stable(feature = "simd_x86", since = "1.27.0")]
1898pub fn _mm_sqrt_sd(a: __m128d, b: __m128d) -> __m128d {
1899 unsafe { simd_insert!(a, 0, sqrt(_mm_cvtsd_f64(b))) }
1900}
1901
1902#[inline]
1906#[target_feature(enable = "sse2")]
1907#[cfg_attr(test, assert_instr(sqrtpd))]
1908#[stable(feature = "simd_x86", since = "1.27.0")]
1909pub fn _mm_sqrt_pd(a: __m128d) -> __m128d {
1910 unsafe { simd_fsqrt(a) }
1911}
1912
1913#[inline]
1918#[target_feature(enable = "sse2")]
1919#[cfg_attr(test, assert_instr(subsd))]
1920#[stable(feature = "simd_x86", since = "1.27.0")]
1921#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1922pub const fn _mm_sub_sd(a: __m128d, b: __m128d) -> __m128d {
1923 unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) - _mm_cvtsd_f64(b)) }
1924}
1925
1926#[inline]
1931#[target_feature(enable = "sse2")]
1932#[cfg_attr(test, assert_instr(subpd))]
1933#[stable(feature = "simd_x86", since = "1.27.0")]
1934#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1935pub const fn _mm_sub_pd(a: __m128d, b: __m128d) -> __m128d {
1936 unsafe { simd_sub(a, b) }
1937}
1938
1939#[inline]
1944#[target_feature(enable = "sse2")]
1945#[cfg_attr(test, assert_instr(andps))]
1946#[stable(feature = "simd_x86", since = "1.27.0")]
1947#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1948pub const fn _mm_and_pd(a: __m128d, b: __m128d) -> __m128d {
1949 unsafe {
1950 let a: __m128i = transmute(a);
1951 let b: __m128i = transmute(b);
1952 transmute(_mm_and_si128(a, b))
1953 }
1954}
1955
1956#[inline]
1960#[target_feature(enable = "sse2")]
1961#[cfg_attr(test, assert_instr(andnps))]
1962#[stable(feature = "simd_x86", since = "1.27.0")]
1963#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1964pub const fn _mm_andnot_pd(a: __m128d, b: __m128d) -> __m128d {
1965 unsafe {
1966 let a: __m128i = transmute(a);
1967 let b: __m128i = transmute(b);
1968 transmute(_mm_andnot_si128(a, b))
1969 }
1970}
1971
1972#[inline]
1976#[target_feature(enable = "sse2")]
1977#[cfg_attr(test, assert_instr(orps))]
1978#[stable(feature = "simd_x86", since = "1.27.0")]
1979#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1980pub const fn _mm_or_pd(a: __m128d, b: __m128d) -> __m128d {
1981 unsafe {
1982 let a: __m128i = transmute(a);
1983 let b: __m128i = transmute(b);
1984 transmute(_mm_or_si128(a, b))
1985 }
1986}
1987
1988#[inline]
1992#[target_feature(enable = "sse2")]
1993#[cfg_attr(test, assert_instr(xorps))]
1994#[stable(feature = "simd_x86", since = "1.27.0")]
1995#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
1996pub const fn _mm_xor_pd(a: __m128d, b: __m128d) -> __m128d {
1997 unsafe {
1998 let a: __m128i = transmute(a);
1999 let b: __m128i = transmute(b);
2000 transmute(_mm_xor_si128(a, b))
2001 }
2002}
2003
2004#[inline]
2009#[target_feature(enable = "sse2")]
2010#[cfg_attr(test, assert_instr(cmpeqsd))]
2011#[stable(feature = "simd_x86", since = "1.27.0")]
2012pub fn _mm_cmpeq_sd(a: __m128d, b: __m128d) -> __m128d {
2013 unsafe { cmpsd(a, b, 0) }
2014}
2015
2016#[inline]
2021#[target_feature(enable = "sse2")]
2022#[cfg_attr(test, assert_instr(cmpltsd))]
2023#[stable(feature = "simd_x86", since = "1.27.0")]
2024pub fn _mm_cmplt_sd(a: __m128d, b: __m128d) -> __m128d {
2025 unsafe { cmpsd(a, b, 1) }
2026}
2027
2028#[inline]
2033#[target_feature(enable = "sse2")]
2034#[cfg_attr(test, assert_instr(cmplesd))]
2035#[stable(feature = "simd_x86", since = "1.27.0")]
2036pub fn _mm_cmple_sd(a: __m128d, b: __m128d) -> __m128d {
2037 unsafe { cmpsd(a, b, 2) }
2038}
2039
2040#[inline]
2045#[target_feature(enable = "sse2")]
2046#[cfg_attr(test, assert_instr(cmpltsd))]
2047#[stable(feature = "simd_x86", since = "1.27.0")]
2048pub fn _mm_cmpgt_sd(a: __m128d, b: __m128d) -> __m128d {
2049 unsafe { simd_insert!(_mm_cmplt_sd(b, a), 1, simd_extract!(a, 1, f64)) }
2050}
2051
2052#[inline]
2057#[target_feature(enable = "sse2")]
2058#[cfg_attr(test, assert_instr(cmplesd))]
2059#[stable(feature = "simd_x86", since = "1.27.0")]
2060pub fn _mm_cmpge_sd(a: __m128d, b: __m128d) -> __m128d {
2061 unsafe { simd_insert!(_mm_cmple_sd(b, a), 1, simd_extract!(a, 1, f64)) }
2062}
2063
2064#[inline]
2071#[target_feature(enable = "sse2")]
2072#[cfg_attr(test, assert_instr(cmpordsd))]
2073#[stable(feature = "simd_x86", since = "1.27.0")]
2074pub fn _mm_cmpord_sd(a: __m128d, b: __m128d) -> __m128d {
2075 unsafe { cmpsd(a, b, 7) }
2076}
2077
2078#[inline]
2084#[target_feature(enable = "sse2")]
2085#[cfg_attr(test, assert_instr(cmpunordsd))]
2086#[stable(feature = "simd_x86", since = "1.27.0")]
2087pub fn _mm_cmpunord_sd(a: __m128d, b: __m128d) -> __m128d {
2088 unsafe { cmpsd(a, b, 3) }
2089}
2090
2091#[inline]
2096#[target_feature(enable = "sse2")]
2097#[cfg_attr(test, assert_instr(cmpneqsd))]
2098#[stable(feature = "simd_x86", since = "1.27.0")]
2099pub fn _mm_cmpneq_sd(a: __m128d, b: __m128d) -> __m128d {
2100 unsafe { cmpsd(a, b, 4) }
2101}
2102
2103#[inline]
2108#[target_feature(enable = "sse2")]
2109#[cfg_attr(test, assert_instr(cmpnltsd))]
2110#[stable(feature = "simd_x86", since = "1.27.0")]
2111pub fn _mm_cmpnlt_sd(a: __m128d, b: __m128d) -> __m128d {
2112 unsafe { cmpsd(a, b, 5) }
2113}
2114
2115#[inline]
2120#[target_feature(enable = "sse2")]
2121#[cfg_attr(test, assert_instr(cmpnlesd))]
2122#[stable(feature = "simd_x86", since = "1.27.0")]
2123pub fn _mm_cmpnle_sd(a: __m128d, b: __m128d) -> __m128d {
2124 unsafe { cmpsd(a, b, 6) }
2125}
2126
2127#[inline]
2132#[target_feature(enable = "sse2")]
2133#[cfg_attr(test, assert_instr(cmpnltsd))]
2134#[stable(feature = "simd_x86", since = "1.27.0")]
2135pub fn _mm_cmpngt_sd(a: __m128d, b: __m128d) -> __m128d {
2136 unsafe { simd_insert!(_mm_cmpnlt_sd(b, a), 1, simd_extract!(a, 1, f64)) }
2137}
2138
2139#[inline]
2144#[target_feature(enable = "sse2")]
2145#[cfg_attr(test, assert_instr(cmpnlesd))]
2146#[stable(feature = "simd_x86", since = "1.27.0")]
2147pub fn _mm_cmpnge_sd(a: __m128d, b: __m128d) -> __m128d {
2148 unsafe { simd_insert!(_mm_cmpnle_sd(b, a), 1, simd_extract!(a, 1, f64)) }
2149}
2150
2151#[inline]
2155#[target_feature(enable = "sse2")]
2156#[cfg_attr(test, assert_instr(cmpeqpd))]
2157#[stable(feature = "simd_x86", since = "1.27.0")]
2158pub fn _mm_cmpeq_pd(a: __m128d, b: __m128d) -> __m128d {
2159 unsafe { cmppd(a, b, 0) }
2160}
2161
2162#[inline]
2166#[target_feature(enable = "sse2")]
2167#[cfg_attr(test, assert_instr(cmpltpd))]
2168#[stable(feature = "simd_x86", since = "1.27.0")]
2169pub fn _mm_cmplt_pd(a: __m128d, b: __m128d) -> __m128d {
2170 unsafe { cmppd(a, b, 1) }
2171}
2172
2173#[inline]
2177#[target_feature(enable = "sse2")]
2178#[cfg_attr(test, assert_instr(cmplepd))]
2179#[stable(feature = "simd_x86", since = "1.27.0")]
2180pub fn _mm_cmple_pd(a: __m128d, b: __m128d) -> __m128d {
2181 unsafe { cmppd(a, b, 2) }
2182}
2183
2184#[inline]
2188#[target_feature(enable = "sse2")]
2189#[cfg_attr(test, assert_instr(cmpltpd))]
2190#[stable(feature = "simd_x86", since = "1.27.0")]
2191pub fn _mm_cmpgt_pd(a: __m128d, b: __m128d) -> __m128d {
2192 _mm_cmplt_pd(b, a)
2193}
2194
2195#[inline]
2199#[target_feature(enable = "sse2")]
2200#[cfg_attr(test, assert_instr(cmplepd))]
2201#[stable(feature = "simd_x86", since = "1.27.0")]
2202pub fn _mm_cmpge_pd(a: __m128d, b: __m128d) -> __m128d {
2203 _mm_cmple_pd(b, a)
2204}
2205
2206#[inline]
2210#[target_feature(enable = "sse2")]
2211#[cfg_attr(test, assert_instr(cmpordpd))]
2212#[stable(feature = "simd_x86", since = "1.27.0")]
2213pub fn _mm_cmpord_pd(a: __m128d, b: __m128d) -> __m128d {
2214 unsafe { cmppd(a, b, 7) }
2215}
2216
2217#[inline]
2221#[target_feature(enable = "sse2")]
2222#[cfg_attr(test, assert_instr(cmpunordpd))]
2223#[stable(feature = "simd_x86", since = "1.27.0")]
2224pub fn _mm_cmpunord_pd(a: __m128d, b: __m128d) -> __m128d {
2225 unsafe { cmppd(a, b, 3) }
2226}
2227
2228#[inline]
2232#[target_feature(enable = "sse2")]
2233#[cfg_attr(test, assert_instr(cmpneqpd))]
2234#[stable(feature = "simd_x86", since = "1.27.0")]
2235pub fn _mm_cmpneq_pd(a: __m128d, b: __m128d) -> __m128d {
2236 unsafe { cmppd(a, b, 4) }
2237}
2238
2239#[inline]
2243#[target_feature(enable = "sse2")]
2244#[cfg_attr(test, assert_instr(cmpnltpd))]
2245#[stable(feature = "simd_x86", since = "1.27.0")]
2246pub fn _mm_cmpnlt_pd(a: __m128d, b: __m128d) -> __m128d {
2247 unsafe { cmppd(a, b, 5) }
2248}
2249
2250#[inline]
2254#[target_feature(enable = "sse2")]
2255#[cfg_attr(test, assert_instr(cmpnlepd))]
2256#[stable(feature = "simd_x86", since = "1.27.0")]
2257pub fn _mm_cmpnle_pd(a: __m128d, b: __m128d) -> __m128d {
2258 unsafe { cmppd(a, b, 6) }
2259}
2260
2261#[inline]
2265#[target_feature(enable = "sse2")]
2266#[cfg_attr(test, assert_instr(cmpnltpd))]
2267#[stable(feature = "simd_x86", since = "1.27.0")]
2268pub fn _mm_cmpngt_pd(a: __m128d, b: __m128d) -> __m128d {
2269 _mm_cmpnlt_pd(b, a)
2270}
2271
2272#[inline]
2277#[target_feature(enable = "sse2")]
2278#[cfg_attr(test, assert_instr(cmpnlepd))]
2279#[stable(feature = "simd_x86", since = "1.27.0")]
2280pub fn _mm_cmpnge_pd(a: __m128d, b: __m128d) -> __m128d {
2281 _mm_cmpnle_pd(b, a)
2282}
2283
2284#[inline]
2288#[target_feature(enable = "sse2")]
2289#[cfg_attr(test, assert_instr(comisd))]
2290#[stable(feature = "simd_x86", since = "1.27.0")]
2291pub fn _mm_comieq_sd(a: __m128d, b: __m128d) -> i32 {
2292 unsafe { comieqsd(a, b) }
2293}
2294
2295#[inline]
2299#[target_feature(enable = "sse2")]
2300#[cfg_attr(test, assert_instr(comisd))]
2301#[stable(feature = "simd_x86", since = "1.27.0")]
2302pub fn _mm_comilt_sd(a: __m128d, b: __m128d) -> i32 {
2303 unsafe { comiltsd(a, b) }
2304}
2305
2306#[inline]
2310#[target_feature(enable = "sse2")]
2311#[cfg_attr(test, assert_instr(comisd))]
2312#[stable(feature = "simd_x86", since = "1.27.0")]
2313pub fn _mm_comile_sd(a: __m128d, b: __m128d) -> i32 {
2314 unsafe { comilesd(a, b) }
2315}
2316
2317#[inline]
2321#[target_feature(enable = "sse2")]
2322#[cfg_attr(test, assert_instr(comisd))]
2323#[stable(feature = "simd_x86", since = "1.27.0")]
2324pub fn _mm_comigt_sd(a: __m128d, b: __m128d) -> i32 {
2325 unsafe { comigtsd(a, b) }
2326}
2327
2328#[inline]
2332#[target_feature(enable = "sse2")]
2333#[cfg_attr(test, assert_instr(comisd))]
2334#[stable(feature = "simd_x86", since = "1.27.0")]
2335pub fn _mm_comige_sd(a: __m128d, b: __m128d) -> i32 {
2336 unsafe { comigesd(a, b) }
2337}
2338
2339#[inline]
2343#[target_feature(enable = "sse2")]
2344#[cfg_attr(test, assert_instr(comisd))]
2345#[stable(feature = "simd_x86", since = "1.27.0")]
2346pub fn _mm_comineq_sd(a: __m128d, b: __m128d) -> i32 {
2347 unsafe { comineqsd(a, b) }
2348}
2349
2350#[inline]
2354#[target_feature(enable = "sse2")]
2355#[cfg_attr(test, assert_instr(ucomisd))]
2356#[stable(feature = "simd_x86", since = "1.27.0")]
2357pub fn _mm_ucomieq_sd(a: __m128d, b: __m128d) -> i32 {
2358 unsafe { ucomieqsd(a, b) }
2359}
2360
2361#[inline]
2365#[target_feature(enable = "sse2")]
2366#[cfg_attr(test, assert_instr(ucomisd))]
2367#[stable(feature = "simd_x86", since = "1.27.0")]
2368pub fn _mm_ucomilt_sd(a: __m128d, b: __m128d) -> i32 {
2369 unsafe { ucomiltsd(a, b) }
2370}
2371
2372#[inline]
2376#[target_feature(enable = "sse2")]
2377#[cfg_attr(test, assert_instr(ucomisd))]
2378#[stable(feature = "simd_x86", since = "1.27.0")]
2379pub fn _mm_ucomile_sd(a: __m128d, b: __m128d) -> i32 {
2380 unsafe { ucomilesd(a, b) }
2381}
2382
2383#[inline]
2387#[target_feature(enable = "sse2")]
2388#[cfg_attr(test, assert_instr(ucomisd))]
2389#[stable(feature = "simd_x86", since = "1.27.0")]
2390pub fn _mm_ucomigt_sd(a: __m128d, b: __m128d) -> i32 {
2391 unsafe { ucomigtsd(a, b) }
2392}
2393
2394#[inline]
2398#[target_feature(enable = "sse2")]
2399#[cfg_attr(test, assert_instr(ucomisd))]
2400#[stable(feature = "simd_x86", since = "1.27.0")]
2401pub fn _mm_ucomige_sd(a: __m128d, b: __m128d) -> i32 {
2402 unsafe { ucomigesd(a, b) }
2403}
2404
2405#[inline]
2409#[target_feature(enable = "sse2")]
2410#[cfg_attr(test, assert_instr(ucomisd))]
2411#[stable(feature = "simd_x86", since = "1.27.0")]
2412pub fn _mm_ucomineq_sd(a: __m128d, b: __m128d) -> i32 {
2413 unsafe { ucomineqsd(a, b) }
2414}
2415
2416#[inline]
2421#[target_feature(enable = "sse2")]
2422#[cfg_attr(test, assert_instr(cvtpd2ps))]
2423#[stable(feature = "simd_x86", since = "1.27.0")]
2424#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2425pub const fn _mm_cvtpd_ps(a: __m128d) -> __m128 {
2426 unsafe {
2427 let r = simd_cast::<_, f32x2>(a.as_f64x2());
2428 let zero = f32x2::ZERO;
2429 transmute::<f32x4, _>(simd_shuffle!(r, zero, [0, 1, 2, 3]))
2430 }
2431}
2432
2433#[inline]
2439#[target_feature(enable = "sse2")]
2440#[cfg_attr(test, assert_instr(cvtps2pd))]
2441#[stable(feature = "simd_x86", since = "1.27.0")]
2442#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2443pub const fn _mm_cvtps_pd(a: __m128) -> __m128d {
2444 unsafe {
2445 let a = a.as_f32x4();
2446 transmute(simd_cast::<f32x2, f64x2>(simd_shuffle!(a, a, [0, 1])))
2447 }
2448}
2449
2450#[inline]
2455#[target_feature(enable = "sse2")]
2456#[cfg_attr(test, assert_instr(cvtpd2dq))]
2457#[stable(feature = "simd_x86", since = "1.27.0")]
2458pub fn _mm_cvtpd_epi32(a: __m128d) -> __m128i {
2459 unsafe { transmute(cvtpd2dq(a)) }
2460}
2461
2462#[inline]
2467#[target_feature(enable = "sse2")]
2468#[cfg_attr(test, assert_instr(cvtsd2si))]
2469#[stable(feature = "simd_x86", since = "1.27.0")]
2470pub fn _mm_cvtsd_si32(a: __m128d) -> i32 {
2471 unsafe { cvtsd2si(a) }
2472}
2473
2474#[inline]
2481#[target_feature(enable = "sse2")]
2482#[cfg_attr(test, assert_instr(cvtsd2ss))]
2483#[stable(feature = "simd_x86", since = "1.27.0")]
2484pub fn _mm_cvtsd_ss(a: __m128, b: __m128d) -> __m128 {
2485 unsafe { cvtsd2ss(a, b) }
2486}
2487
2488#[inline]
2492#[target_feature(enable = "sse2")]
2493#[stable(feature = "simd_x86", since = "1.27.0")]
2494#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2495pub const fn _mm_cvtsd_f64(a: __m128d) -> f64 {
2496 unsafe { simd_extract!(a, 0) }
2497}
2498
2499#[inline]
2506#[target_feature(enable = "sse2")]
2507#[cfg_attr(test, assert_instr(cvtss2sd))]
2508#[stable(feature = "simd_x86", since = "1.27.0")]
2509#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2510pub const fn _mm_cvtss_sd(a: __m128d, b: __m128) -> __m128d {
2511 unsafe {
2512 let elt: f32 = simd_extract!(b, 0);
2513 simd_insert!(a, 0, elt as f64)
2514 }
2515}
2516
2517#[inline]
2522#[target_feature(enable = "sse2")]
2523#[cfg_attr(test, assert_instr(cvttpd2dq))]
2524#[stable(feature = "simd_x86", since = "1.27.0")]
2525pub fn _mm_cvttpd_epi32(a: __m128d) -> __m128i {
2526 unsafe { transmute(cvttpd2dq(a)) }
2527}
2528
2529#[inline]
2534#[target_feature(enable = "sse2")]
2535#[cfg_attr(test, assert_instr(cvttsd2si))]
2536#[stable(feature = "simd_x86", since = "1.27.0")]
2537pub fn _mm_cvttsd_si32(a: __m128d) -> i32 {
2538 unsafe { cvttsd2si(a) }
2539}
2540
2541#[inline]
2546#[target_feature(enable = "sse2")]
2547#[cfg_attr(test, assert_instr(cvttps2dq))]
2548#[stable(feature = "simd_x86", since = "1.27.0")]
2549pub fn _mm_cvttps_epi32(a: __m128) -> __m128i {
2550 unsafe { transmute(cvttps2dq(a)) }
2551}
2552
2553#[inline]
2558#[target_feature(enable = "sse2")]
2559#[stable(feature = "simd_x86", since = "1.27.0")]
2560#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2561pub const fn _mm_set_sd(a: f64) -> __m128d {
2562 _mm_set_pd(0.0, a)
2563}
2564
2565#[inline]
2570#[target_feature(enable = "sse2")]
2571#[stable(feature = "simd_x86", since = "1.27.0")]
2572#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2573pub const fn _mm_set1_pd(a: f64) -> __m128d {
2574 _mm_set_pd(a, a)
2575}
2576
2577#[inline]
2582#[target_feature(enable = "sse2")]
2583#[stable(feature = "simd_x86", since = "1.27.0")]
2584#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2585pub const fn _mm_set_pd1(a: f64) -> __m128d {
2586 _mm_set_pd(a, a)
2587}
2588
2589#[inline]
2594#[target_feature(enable = "sse2")]
2595#[stable(feature = "simd_x86", since = "1.27.0")]
2596#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2597pub const fn _mm_set_pd(a: f64, b: f64) -> __m128d {
2598 __m128d([b, a])
2599}
2600
2601#[inline]
2606#[target_feature(enable = "sse2")]
2607#[stable(feature = "simd_x86", since = "1.27.0")]
2608#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2609pub const fn _mm_setr_pd(a: f64, b: f64) -> __m128d {
2610 _mm_set_pd(b, a)
2611}
2612
2613#[inline]
2618#[target_feature(enable = "sse2")]
2619#[cfg_attr(test, assert_instr(xorp))]
2620#[stable(feature = "simd_x86", since = "1.27.0")]
2621#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2622pub const fn _mm_setzero_pd() -> __m128d {
2623 const { unsafe { mem::zeroed() } }
2624}
2625
2626#[inline]
2633#[target_feature(enable = "sse2")]
2634#[cfg_attr(test, assert_instr(movmskpd))]
2635#[stable(feature = "simd_x86", since = "1.27.0")]
2636#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2637pub const fn _mm_movemask_pd(a: __m128d) -> i32 {
2638 unsafe {
2641 let mask: i64x2 = simd_lt(transmute(a), i64x2::ZERO);
2642 simd_bitmask::<i64x2, u8>(mask) as i32
2643 }
2644}
2645
2646#[inline]
2653#[target_feature(enable = "sse2")]
2654#[cfg_attr(
2655 all(test, not(all(target_arch = "x86", target_env = "msvc"))),
2656 assert_instr(movaps)
2657)]
2658#[stable(feature = "simd_x86", since = "1.27.0")]
2659#[allow(clippy::cast_ptr_alignment)]
2660#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2661pub const unsafe fn _mm_load_pd(mem_addr: *const f64) -> __m128d {
2662 *(mem_addr as *const __m128d)
2663}
2664
2665#[inline]
2670#[target_feature(enable = "sse2")]
2671#[cfg_attr(test, assert_instr(movsd))]
2672#[stable(feature = "simd_x86", since = "1.27.0")]
2673#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2674pub const unsafe fn _mm_load_sd(mem_addr: *const f64) -> __m128d {
2675 _mm_setr_pd(*mem_addr, 0.)
2676}
2677
2678#[inline]
2684#[target_feature(enable = "sse2")]
2685#[cfg_attr(test, assert_instr(movhps))]
2686#[stable(feature = "simd_x86", since = "1.27.0")]
2687#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2688pub const unsafe fn _mm_loadh_pd(a: __m128d, mem_addr: *const f64) -> __m128d {
2689 _mm_setr_pd(simd_extract!(a, 0), *mem_addr)
2690}
2691
2692#[inline]
2698#[target_feature(enable = "sse2")]
2699#[cfg_attr(test, assert_instr(movlps))]
2700#[stable(feature = "simd_x86", since = "1.27.0")]
2701#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2702pub const unsafe fn _mm_loadl_pd(a: __m128d, mem_addr: *const f64) -> __m128d {
2703 _mm_setr_pd(*mem_addr, simd_extract!(a, 1))
2704}
2705
2706#[inline]
2722#[target_feature(enable = "sse2")]
2723#[cfg_attr(test, assert_instr(movntpd))]
2724#[stable(feature = "simd_x86", since = "1.27.0")]
2725#[allow(clippy::cast_ptr_alignment)]
2726pub unsafe fn _mm_stream_pd(mem_addr: *mut f64, a: __m128d) {
2727 crate::arch::asm!(
2729 vps!("movntpd", ",{a}"),
2730 p = in(reg) mem_addr,
2731 a = in(xmm_reg) a,
2732 options(nostack, preserves_flags),
2733 );
2734}
2735
2736#[inline]
2741#[target_feature(enable = "sse2")]
2742#[cfg_attr(test, assert_instr(movlps))]
2743#[stable(feature = "simd_x86", since = "1.27.0")]
2744#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2745pub const unsafe fn _mm_store_sd(mem_addr: *mut f64, a: __m128d) {
2746 *mem_addr = simd_extract!(a, 0)
2747}
2748
2749#[inline]
2755#[target_feature(enable = "sse2")]
2756#[cfg_attr(
2757 all(test, not(all(target_arch = "x86", target_env = "msvc"))),
2758 assert_instr(movaps)
2759)]
2760#[stable(feature = "simd_x86", since = "1.27.0")]
2761#[allow(clippy::cast_ptr_alignment)]
2762#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2763pub const unsafe fn _mm_store_pd(mem_addr: *mut f64, a: __m128d) {
2764 *(mem_addr as *mut __m128d) = a;
2765}
2766
2767#[inline]
2773#[target_feature(enable = "sse2")]
2774#[cfg_attr(test, assert_instr(movups))] #[stable(feature = "simd_x86", since = "1.27.0")]
2776#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2777pub const unsafe fn _mm_storeu_pd(mem_addr: *mut f64, a: __m128d) {
2778 mem_addr.cast::<__m128d>().write_unaligned(a);
2779}
2780
2781#[inline]
2787#[target_feature(enable = "sse2")]
2788#[stable(feature = "simd_x86_updates", since = "1.82.0")]
2789#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2790pub const unsafe fn _mm_storeu_si16(mem_addr: *mut u8, a: __m128i) {
2791 ptr::write_unaligned(mem_addr as *mut i16, simd_extract(a.as_i16x8(), 0))
2792}
2793
2794#[inline]
2800#[target_feature(enable = "sse2")]
2801#[stable(feature = "simd_x86_updates", since = "1.82.0")]
2802#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2803pub const unsafe fn _mm_storeu_si32(mem_addr: *mut u8, a: __m128i) {
2804 ptr::write_unaligned(mem_addr as *mut i32, simd_extract(a.as_i32x4(), 0))
2805}
2806
2807#[inline]
2813#[target_feature(enable = "sse2")]
2814#[stable(feature = "simd_x86_updates", since = "1.82.0")]
2815#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2816pub const unsafe fn _mm_storeu_si64(mem_addr: *mut u8, a: __m128i) {
2817 ptr::write_unaligned(mem_addr as *mut i64, simd_extract(a.as_i64x2(), 0))
2818}
2819
2820#[inline]
2826#[target_feature(enable = "sse2")]
2827#[stable(feature = "simd_x86", since = "1.27.0")]
2828#[allow(clippy::cast_ptr_alignment)]
2829#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2830pub const unsafe fn _mm_store1_pd(mem_addr: *mut f64, a: __m128d) {
2831 let b: __m128d = simd_shuffle!(a, a, [0, 0]);
2832 *(mem_addr as *mut __m128d) = b;
2833}
2834
2835#[inline]
2841#[target_feature(enable = "sse2")]
2842#[stable(feature = "simd_x86", since = "1.27.0")]
2843#[allow(clippy::cast_ptr_alignment)]
2844#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2845pub const unsafe fn _mm_store_pd1(mem_addr: *mut f64, a: __m128d) {
2846 let b: __m128d = simd_shuffle!(a, a, [0, 0]);
2847 *(mem_addr as *mut __m128d) = b;
2848}
2849
2850#[inline]
2857#[target_feature(enable = "sse2")]
2858#[stable(feature = "simd_x86", since = "1.27.0")]
2859#[allow(clippy::cast_ptr_alignment)]
2860#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2861pub const unsafe fn _mm_storer_pd(mem_addr: *mut f64, a: __m128d) {
2862 let b: __m128d = simd_shuffle!(a, a, [1, 0]);
2863 *(mem_addr as *mut __m128d) = b;
2864}
2865
2866#[inline]
2871#[target_feature(enable = "sse2")]
2872#[cfg_attr(test, assert_instr(movhps))]
2873#[stable(feature = "simd_x86", since = "1.27.0")]
2874#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2875pub const unsafe fn _mm_storeh_pd(mem_addr: *mut f64, a: __m128d) {
2876 *mem_addr = simd_extract!(a, 1);
2877}
2878
2879#[inline]
2884#[target_feature(enable = "sse2")]
2885#[cfg_attr(test, assert_instr(movlps))]
2886#[stable(feature = "simd_x86", since = "1.27.0")]
2887#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2888pub const unsafe fn _mm_storel_pd(mem_addr: *mut f64, a: __m128d) {
2889 *mem_addr = simd_extract!(a, 0);
2890}
2891
2892#[inline]
2897#[target_feature(enable = "sse2")]
2898#[stable(feature = "simd_x86", since = "1.27.0")]
2900#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2901pub const unsafe fn _mm_load1_pd(mem_addr: *const f64) -> __m128d {
2902 let d = *mem_addr;
2903 _mm_setr_pd(d, d)
2904}
2905
2906#[inline]
2911#[target_feature(enable = "sse2")]
2912#[stable(feature = "simd_x86", since = "1.27.0")]
2914#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2915pub const unsafe fn _mm_load_pd1(mem_addr: *const f64) -> __m128d {
2916 _mm_load1_pd(mem_addr)
2917}
2918
2919#[inline]
2925#[target_feature(enable = "sse2")]
2926#[cfg_attr(
2927 all(test, not(all(target_arch = "x86", target_env = "msvc"))),
2928 assert_instr(movaps)
2929)]
2930#[stable(feature = "simd_x86", since = "1.27.0")]
2931#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2932pub const unsafe fn _mm_loadr_pd(mem_addr: *const f64) -> __m128d {
2933 let a = _mm_load_pd(mem_addr);
2934 simd_shuffle!(a, a, [1, 0])
2935}
2936
2937#[inline]
2943#[target_feature(enable = "sse2")]
2944#[cfg_attr(test, assert_instr(movups))]
2945#[stable(feature = "simd_x86", since = "1.27.0")]
2946#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2947pub const unsafe fn _mm_loadu_pd(mem_addr: *const f64) -> __m128d {
2948 let mut dst = _mm_undefined_pd();
2949 ptr::copy_nonoverlapping(
2950 mem_addr as *const u8,
2951 ptr::addr_of_mut!(dst) as *mut u8,
2952 mem::size_of::<__m128d>(),
2953 );
2954 dst
2955}
2956
2957#[inline]
2963#[target_feature(enable = "sse2")]
2964#[stable(feature = "simd_x86_updates", since = "1.82.0")]
2965#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2966pub const unsafe fn _mm_loadu_si16(mem_addr: *const u8) -> __m128i {
2967 transmute(i16x8::new(
2968 ptr::read_unaligned(mem_addr as *const i16),
2969 0,
2970 0,
2971 0,
2972 0,
2973 0,
2974 0,
2975 0,
2976 ))
2977}
2978
2979#[inline]
2985#[target_feature(enable = "sse2")]
2986#[stable(feature = "simd_x86_updates", since = "1.82.0")]
2987#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
2988pub const unsafe fn _mm_loadu_si32(mem_addr: *const u8) -> __m128i {
2989 transmute(i32x4::new(
2990 ptr::read_unaligned(mem_addr as *const i32),
2991 0,
2992 0,
2993 0,
2994 ))
2995}
2996
2997#[inline]
3003#[target_feature(enable = "sse2")]
3004#[stable(feature = "simd_x86_mm_loadu_si64", since = "1.46.0")]
3005#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3006pub const unsafe fn _mm_loadu_si64(mem_addr: *const u8) -> __m128i {
3007 transmute(i64x2::new(ptr::read_unaligned(mem_addr as *const i64), 0))
3008}
3009
3010#[inline]
3016#[target_feature(enable = "sse2")]
3017#[cfg_attr(test, assert_instr(shufps, MASK = 2))]
3018#[rustc_legacy_const_generics(2)]
3019#[stable(feature = "simd_x86", since = "1.27.0")]
3020#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3021pub const fn _mm_shuffle_pd<const MASK: i32>(a: __m128d, b: __m128d) -> __m128d {
3022 static_assert_uimm_bits!(MASK, 8);
3023 unsafe { simd_shuffle!(a, b, [MASK as u32 & 0b1, ((MASK as u32 >> 1) & 0b1) + 2]) }
3024}
3025
3026#[inline]
3032#[target_feature(enable = "sse2")]
3033#[cfg_attr(test, assert_instr(movsd))]
3034#[stable(feature = "simd_x86", since = "1.27.0")]
3035#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3036pub const fn _mm_move_sd(a: __m128d, b: __m128d) -> __m128d {
3037 unsafe { _mm_setr_pd(simd_extract!(b, 0), simd_extract!(a, 1)) }
3038}
3039
3040#[inline]
3045#[target_feature(enable = "sse2")]
3046#[stable(feature = "simd_x86", since = "1.27.0")]
3047#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3048pub const fn _mm_castpd_ps(a: __m128d) -> __m128 {
3049 unsafe { transmute(a) }
3050}
3051
3052#[inline]
3057#[target_feature(enable = "sse2")]
3058#[stable(feature = "simd_x86", since = "1.27.0")]
3059#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3060pub const fn _mm_castpd_si128(a: __m128d) -> __m128i {
3061 unsafe { transmute(a) }
3062}
3063
3064#[inline]
3069#[target_feature(enable = "sse2")]
3070#[stable(feature = "simd_x86", since = "1.27.0")]
3071#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3072pub const fn _mm_castps_pd(a: __m128) -> __m128d {
3073 unsafe { transmute(a) }
3074}
3075
3076#[inline]
3081#[target_feature(enable = "sse2")]
3082#[stable(feature = "simd_x86", since = "1.27.0")]
3083#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3084pub const fn _mm_castps_si128(a: __m128) -> __m128i {
3085 unsafe { transmute(a) }
3086}
3087
3088#[inline]
3093#[target_feature(enable = "sse2")]
3094#[stable(feature = "simd_x86", since = "1.27.0")]
3095#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3096pub const fn _mm_castsi128_pd(a: __m128i) -> __m128d {
3097 unsafe { transmute(a) }
3098}
3099
3100#[inline]
3105#[target_feature(enable = "sse2")]
3106#[stable(feature = "simd_x86", since = "1.27.0")]
3107#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3108pub const fn _mm_castsi128_ps(a: __m128i) -> __m128 {
3109 unsafe { transmute(a) }
3110}
3111
3112#[inline]
3119#[target_feature(enable = "sse2")]
3120#[stable(feature = "simd_x86", since = "1.27.0")]
3121#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3122pub const fn _mm_undefined_pd() -> __m128d {
3123 const { unsafe { mem::zeroed() } }
3124}
3125
3126#[ferrocene::prevalidated]
3133#[inline]
3134#[target_feature(enable = "sse2")]
3135#[stable(feature = "simd_x86", since = "1.27.0")]
3136#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3137pub const fn _mm_undefined_si128() -> __m128i {
3138 const { unsafe { mem::zeroed() } }
3139}
3140
3141#[inline]
3149#[target_feature(enable = "sse2")]
3150#[cfg_attr(test, assert_instr(unpckhpd))]
3151#[stable(feature = "simd_x86", since = "1.27.0")]
3152#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3153pub const fn _mm_unpackhi_pd(a: __m128d, b: __m128d) -> __m128d {
3154 unsafe { simd_shuffle!(a, b, [1, 3]) }
3155}
3156
3157#[inline]
3165#[target_feature(enable = "sse2")]
3166#[cfg_attr(test, assert_instr(movlhps))]
3167#[stable(feature = "simd_x86", since = "1.27.0")]
3168#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
3169pub const fn _mm_unpacklo_pd(a: __m128d, b: __m128d) -> __m128d {
3170 unsafe { simd_shuffle!(a, b, [0, 2]) }
3171}
3172
3173#[allow(improper_ctypes)]
3174unsafe extern "llvm-intrinsic" {
3175 #[link_name = "llvm.x86.sse2.pause"]
3176 fn pause();
3177 #[link_name = "llvm.x86.sse2.clflush"]
3178 fn clflush(p: *const u8);
3179 #[link_name = "llvm.x86.sse2.lfence"]
3180 fn lfence();
3181 #[link_name = "llvm.x86.sse2.mfence"]
3182 fn mfence();
3183 #[link_name = "llvm.x86.sse2.pavg.b"]
3184 fn pavgb(a: u8x16, b: u8x16) -> u8x16;
3185 #[link_name = "llvm.x86.sse2.pavg.w"]
3186 fn pavgw(a: u16x8, b: u16x8) -> u16x8;
3187 #[link_name = "llvm.x86.sse2.pmadd.wd"]
3188 fn pmaddwd(a: i16x8, b: i16x8) -> i32x4;
3189 #[link_name = "llvm.x86.sse2.pmulh.w"]
3190 fn pmulhw(a: i16x8, b: i16x8) -> i16x8;
3191 #[link_name = "llvm.x86.sse2.pmulhu.w"]
3192 fn pmulhuw(a: u16x8, b: u16x8) -> u16x8;
3193 #[link_name = "llvm.x86.sse2.psad.bw"]
3194 fn psadbw(a: u8x16, b: u8x16) -> u64x2;
3195 #[link_name = "llvm.x86.sse2.psll.w"]
3196 fn psllw(a: i16x8, count: i16x8) -> i16x8;
3197 #[link_name = "llvm.x86.sse2.psll.d"]
3198 fn pslld(a: i32x4, count: i32x4) -> i32x4;
3199 #[link_name = "llvm.x86.sse2.psll.q"]
3200 fn psllq(a: i64x2, count: i64x2) -> i64x2;
3201 #[link_name = "llvm.x86.sse2.psra.w"]
3202 fn psraw(a: i16x8, count: i16x8) -> i16x8;
3203 #[link_name = "llvm.x86.sse2.psra.d"]
3204 fn psrad(a: i32x4, count: i32x4) -> i32x4;
3205 #[link_name = "llvm.x86.sse2.psrl.w"]
3206 fn psrlw(a: i16x8, count: i16x8) -> i16x8;
3207 #[link_name = "llvm.x86.sse2.psrl.d"]
3208 fn psrld(a: i32x4, count: i32x4) -> i32x4;
3209 #[link_name = "llvm.x86.sse2.psrl.q"]
3210 fn psrlq(a: i64x2, count: i64x2) -> i64x2;
3211 #[link_name = "llvm.x86.sse2.cvtps2dq"]
3212 fn cvtps2dq(a: __m128) -> i32x4;
3213 #[link_name = "llvm.x86.sse2.maskmov.dqu"]
3214 fn maskmovdqu(a: i8x16, mask: i8x16, mem_addr: *mut i8);
3215 #[link_name = "llvm.x86.sse2.packsswb.128"]
3216 fn packsswb(a: i16x8, b: i16x8) -> i8x16;
3217 #[link_name = "llvm.x86.sse2.packssdw.128"]
3218 fn packssdw(a: i32x4, b: i32x4) -> i16x8;
3219 #[link_name = "llvm.x86.sse2.packuswb.128"]
3220 fn packuswb(a: i16x8, b: i16x8) -> u8x16;
3221 #[link_name = "llvm.x86.sse2.max.sd"]
3222 fn maxsd(a: __m128d, b: __m128d) -> __m128d;
3223 #[link_name = "llvm.x86.sse2.max.pd"]
3224 fn maxpd(a: __m128d, b: __m128d) -> __m128d;
3225 #[link_name = "llvm.x86.sse2.min.sd"]
3226 fn minsd(a: __m128d, b: __m128d) -> __m128d;
3227 #[link_name = "llvm.x86.sse2.min.pd"]
3228 fn minpd(a: __m128d, b: __m128d) -> __m128d;
3229 #[link_name = "llvm.x86.sse2.cmp.sd"]
3230 fn cmpsd(a: __m128d, b: __m128d, imm8: i8) -> __m128d;
3231 #[link_name = "llvm.x86.sse2.cmp.pd"]
3232 fn cmppd(a: __m128d, b: __m128d, imm8: i8) -> __m128d;
3233 #[link_name = "llvm.x86.sse2.comieq.sd"]
3234 fn comieqsd(a: __m128d, b: __m128d) -> i32;
3235 #[link_name = "llvm.x86.sse2.comilt.sd"]
3236 fn comiltsd(a: __m128d, b: __m128d) -> i32;
3237 #[link_name = "llvm.x86.sse2.comile.sd"]
3238 fn comilesd(a: __m128d, b: __m128d) -> i32;
3239 #[link_name = "llvm.x86.sse2.comigt.sd"]
3240 fn comigtsd(a: __m128d, b: __m128d) -> i32;
3241 #[link_name = "llvm.x86.sse2.comige.sd"]
3242 fn comigesd(a: __m128d, b: __m128d) -> i32;
3243 #[link_name = "llvm.x86.sse2.comineq.sd"]
3244 fn comineqsd(a: __m128d, b: __m128d) -> i32;
3245 #[link_name = "llvm.x86.sse2.ucomieq.sd"]
3246 fn ucomieqsd(a: __m128d, b: __m128d) -> i32;
3247 #[link_name = "llvm.x86.sse2.ucomilt.sd"]
3248 fn ucomiltsd(a: __m128d, b: __m128d) -> i32;
3249 #[link_name = "llvm.x86.sse2.ucomile.sd"]
3250 fn ucomilesd(a: __m128d, b: __m128d) -> i32;
3251 #[link_name = "llvm.x86.sse2.ucomigt.sd"]
3252 fn ucomigtsd(a: __m128d, b: __m128d) -> i32;
3253 #[link_name = "llvm.x86.sse2.ucomige.sd"]
3254 fn ucomigesd(a: __m128d, b: __m128d) -> i32;
3255 #[link_name = "llvm.x86.sse2.ucomineq.sd"]
3256 fn ucomineqsd(a: __m128d, b: __m128d) -> i32;
3257 #[link_name = "llvm.x86.sse2.cvtpd2dq"]
3258 fn cvtpd2dq(a: __m128d) -> i32x4;
3259 #[link_name = "llvm.x86.sse2.cvtsd2si"]
3260 fn cvtsd2si(a: __m128d) -> i32;
3261 #[link_name = "llvm.x86.sse2.cvtsd2ss"]
3262 fn cvtsd2ss(a: __m128, b: __m128d) -> __m128;
3263 #[link_name = "llvm.x86.sse2.cvttpd2dq"]
3264 fn cvttpd2dq(a: __m128d) -> i32x4;
3265 #[link_name = "llvm.x86.sse2.cvttsd2si"]
3266 fn cvttsd2si(a: __m128d) -> i32;
3267 #[link_name = "llvm.x86.sse2.cvttps2dq"]
3268 fn cvttps2dq(a: __m128) -> i32x4;
3269}
3270
3271#[cfg(test)]
3272mod tests {
3273 use crate::core_arch::assert_eq_const as assert_eq;
3274 use crate::{
3275 core_arch::{simd::*, x86::*},
3276 hint::black_box,
3277 };
3278 use std::{boxed, mem, ptr};
3279 use stdarch_test::simd_test;
3280
3281 const NAN: f64 = f64::NAN;
3282
3283 #[test]
3284 fn test_mm_pause() {
3285 _mm_pause()
3286 }
3287
3288 #[simd_test(enable = "sse2")]
3289 fn test_mm_clflush() {
3290 let x = 0_u8;
3291 unsafe {
3292 _mm_clflush(ptr::addr_of!(x));
3293 }
3294 }
3295
3296 #[simd_test(enable = "sse2")]
3297 #[cfg_attr(miri, ignore)]
3299 fn test_mm_lfence() {
3300 _mm_lfence();
3301 }
3302
3303 #[simd_test(enable = "sse2")]
3304 #[cfg_attr(miri, ignore)]
3306 fn test_mm_mfence() {
3307 _mm_mfence();
3308 }
3309
3310 #[simd_test(enable = "sse2")]
3311 const fn test_mm_add_epi8() {
3312 let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
3313 #[rustfmt::skip]
3314 let b = _mm_setr_epi8(
3315 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
3316 );
3317 let r = _mm_add_epi8(a, b);
3318 #[rustfmt::skip]
3319 let e = _mm_setr_epi8(
3320 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46,
3321 );
3322 assert_eq_m128i(r, e);
3323 }
3324
3325 #[simd_test(enable = "sse2")]
3326 fn test_mm_add_epi8_overflow() {
3327 let a = _mm_set1_epi8(0x7F);
3328 let b = _mm_set1_epi8(1);
3329 let r = _mm_add_epi8(a, b);
3330 assert_eq_m128i(r, _mm_set1_epi8(-128));
3331 }
3332
3333 #[simd_test(enable = "sse2")]
3334 const fn test_mm_add_epi16() {
3335 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
3336 let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15);
3337 let r = _mm_add_epi16(a, b);
3338 let e = _mm_setr_epi16(8, 10, 12, 14, 16, 18, 20, 22);
3339 assert_eq_m128i(r, e);
3340 }
3341
3342 #[simd_test(enable = "sse2")]
3343 const fn test_mm_add_epi32() {
3344 let a = _mm_setr_epi32(0, 1, 2, 3);
3345 let b = _mm_setr_epi32(4, 5, 6, 7);
3346 let r = _mm_add_epi32(a, b);
3347 let e = _mm_setr_epi32(4, 6, 8, 10);
3348 assert_eq_m128i(r, e);
3349 }
3350
3351 #[simd_test(enable = "sse2")]
3352 const fn test_mm_add_epi64() {
3353 let a = _mm_setr_epi64x(0, 1);
3354 let b = _mm_setr_epi64x(2, 3);
3355 let r = _mm_add_epi64(a, b);
3356 let e = _mm_setr_epi64x(2, 4);
3357 assert_eq_m128i(r, e);
3358 }
3359
3360 #[simd_test(enable = "sse2")]
3361 const fn test_mm_adds_epi8() {
3362 let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
3363 #[rustfmt::skip]
3364 let b = _mm_setr_epi8(
3365 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
3366 );
3367 let r = _mm_adds_epi8(a, b);
3368 #[rustfmt::skip]
3369 let e = _mm_setr_epi8(
3370 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46,
3371 );
3372 assert_eq_m128i(r, e);
3373 }
3374
3375 #[simd_test(enable = "sse2")]
3376 fn test_mm_adds_epi8_saturate_positive() {
3377 let a = _mm_set1_epi8(0x7F);
3378 let b = _mm_set1_epi8(1);
3379 let r = _mm_adds_epi8(a, b);
3380 assert_eq_m128i(r, a);
3381 }
3382
3383 #[simd_test(enable = "sse2")]
3384 fn test_mm_adds_epi8_saturate_negative() {
3385 let a = _mm_set1_epi8(-0x80);
3386 let b = _mm_set1_epi8(-1);
3387 let r = _mm_adds_epi8(a, b);
3388 assert_eq_m128i(r, a);
3389 }
3390
3391 #[simd_test(enable = "sse2")]
3392 const fn test_mm_adds_epi16() {
3393 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
3394 let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15);
3395 let r = _mm_adds_epi16(a, b);
3396 let e = _mm_setr_epi16(8, 10, 12, 14, 16, 18, 20, 22);
3397 assert_eq_m128i(r, e);
3398 }
3399
3400 #[simd_test(enable = "sse2")]
3401 fn test_mm_adds_epi16_saturate_positive() {
3402 let a = _mm_set1_epi16(0x7FFF);
3403 let b = _mm_set1_epi16(1);
3404 let r = _mm_adds_epi16(a, b);
3405 assert_eq_m128i(r, a);
3406 }
3407
3408 #[simd_test(enable = "sse2")]
3409 fn test_mm_adds_epi16_saturate_negative() {
3410 let a = _mm_set1_epi16(-0x8000);
3411 let b = _mm_set1_epi16(-1);
3412 let r = _mm_adds_epi16(a, b);
3413 assert_eq_m128i(r, a);
3414 }
3415
3416 #[simd_test(enable = "sse2")]
3417 const fn test_mm_adds_epu8() {
3418 let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
3419 #[rustfmt::skip]
3420 let b = _mm_setr_epi8(
3421 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
3422 );
3423 let r = _mm_adds_epu8(a, b);
3424 #[rustfmt::skip]
3425 let e = _mm_setr_epi8(
3426 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46,
3427 );
3428 assert_eq_m128i(r, e);
3429 }
3430
3431 #[simd_test(enable = "sse2")]
3432 fn test_mm_adds_epu8_saturate() {
3433 let a = _mm_set1_epi8(!0);
3434 let b = _mm_set1_epi8(1);
3435 let r = _mm_adds_epu8(a, b);
3436 assert_eq_m128i(r, a);
3437 }
3438
3439 #[simd_test(enable = "sse2")]
3440 const fn test_mm_adds_epu16() {
3441 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
3442 let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15);
3443 let r = _mm_adds_epu16(a, b);
3444 let e = _mm_setr_epi16(8, 10, 12, 14, 16, 18, 20, 22);
3445 assert_eq_m128i(r, e);
3446 }
3447
3448 #[simd_test(enable = "sse2")]
3449 fn test_mm_adds_epu16_saturate() {
3450 let a = _mm_set1_epi16(!0);
3451 let b = _mm_set1_epi16(1);
3452 let r = _mm_adds_epu16(a, b);
3453 assert_eq_m128i(r, a);
3454 }
3455
3456 #[simd_test(enable = "sse2")]
3457 fn test_mm_avg_epu8() {
3458 let (a, b) = (_mm_set1_epi8(3), _mm_set1_epi8(9));
3459 let r = _mm_avg_epu8(a, b);
3460 assert_eq_m128i(r, _mm_set1_epi8(6));
3461 }
3462
3463 #[simd_test(enable = "sse2")]
3464 fn test_mm_avg_epu16() {
3465 let (a, b) = (_mm_set1_epi16(3), _mm_set1_epi16(9));
3466 let r = _mm_avg_epu16(a, b);
3467 assert_eq_m128i(r, _mm_set1_epi16(6));
3468 }
3469
3470 #[simd_test(enable = "sse2")]
3471 fn test_mm_madd_epi16() {
3472 let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8);
3473 let b = _mm_setr_epi16(9, 10, 11, 12, 13, 14, 15, 16);
3474 let r = _mm_madd_epi16(a, b);
3475 let e = _mm_setr_epi32(29, 81, 149, 233);
3476 assert_eq_m128i(r, e);
3477
3478 let a = _mm_setr_epi16(
3481 i16::MAX,
3482 i16::MAX,
3483 i16::MIN,
3484 i16::MIN,
3485 i16::MIN,
3486 i16::MAX,
3487 0,
3488 0,
3489 );
3490 let b = _mm_setr_epi16(
3491 i16::MAX,
3492 i16::MAX,
3493 i16::MIN,
3494 i16::MIN,
3495 i16::MAX,
3496 i16::MIN,
3497 0,
3498 0,
3499 );
3500 let r = _mm_madd_epi16(a, b);
3501 let e = _mm_setr_epi32(0x7FFE0002, i32::MIN, -0x7FFF0000, 0);
3502 assert_eq_m128i(r, e);
3503 }
3504
3505 #[simd_test(enable = "sse2")]
3506 const fn test_mm_max_epi16() {
3507 let a = _mm_set1_epi16(1);
3508 let b = _mm_set1_epi16(-1);
3509 let r = _mm_max_epi16(a, b);
3510 assert_eq_m128i(r, a);
3511 }
3512
3513 #[simd_test(enable = "sse2")]
3514 const fn test_mm_max_epu8() {
3515 let a = _mm_set1_epi8(1);
3516 let b = _mm_set1_epi8(!0);
3517 let r = _mm_max_epu8(a, b);
3518 assert_eq_m128i(r, b);
3519 }
3520
3521 #[simd_test(enable = "sse2")]
3522 const fn test_mm_min_epi16() {
3523 let a = _mm_set1_epi16(1);
3524 let b = _mm_set1_epi16(-1);
3525 let r = _mm_min_epi16(a, b);
3526 assert_eq_m128i(r, b);
3527 }
3528
3529 #[simd_test(enable = "sse2")]
3530 const fn test_mm_min_epu8() {
3531 let a = _mm_set1_epi8(1);
3532 let b = _mm_set1_epi8(!0);
3533 let r = _mm_min_epu8(a, b);
3534 assert_eq_m128i(r, a);
3535 }
3536
3537 #[simd_test(enable = "sse2")]
3538 fn test_mm_mulhi_epi16() {
3539 let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(-1001));
3540 let r = _mm_mulhi_epi16(a, b);
3541 assert_eq_m128i(r, _mm_set1_epi16(-16));
3542 }
3543
3544 #[simd_test(enable = "sse2")]
3545 fn test_mm_mulhi_epu16() {
3546 let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(1001));
3547 let r = _mm_mulhi_epu16(a, b);
3548 assert_eq_m128i(r, _mm_set1_epi16(15));
3549 }
3550
3551 #[simd_test(enable = "sse2")]
3552 const fn test_mm_mullo_epi16() {
3553 let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(-1001));
3554 let r = _mm_mullo_epi16(a, b);
3555 assert_eq_m128i(r, _mm_set1_epi16(-17960));
3556 }
3557
3558 #[simd_test(enable = "sse2")]
3559 const fn test_mm_mul_epu32() {
3560 let a = _mm_setr_epi64x(1_000_000_000, 1 << 34);
3561 let b = _mm_setr_epi64x(1_000_000_000, 1 << 35);
3562 let r = _mm_mul_epu32(a, b);
3563 let e = _mm_setr_epi64x(1_000_000_000 * 1_000_000_000, 0);
3564 assert_eq_m128i(r, e);
3565 }
3566
3567 #[simd_test(enable = "sse2")]
3568 fn test_mm_sad_epu8() {
3569 #[rustfmt::skip]
3570 let a = _mm_setr_epi8(
3571 255u8 as i8, 254u8 as i8, 253u8 as i8, 252u8 as i8,
3572 1, 2, 3, 4,
3573 155u8 as i8, 154u8 as i8, 153u8 as i8, 152u8 as i8,
3574 1, 2, 3, 4,
3575 );
3576 let b = _mm_setr_epi8(0, 0, 0, 0, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2);
3577 let r = _mm_sad_epu8(a, b);
3578 let e = _mm_setr_epi64x(1020, 614);
3579 assert_eq_m128i(r, e);
3580 }
3581
3582 #[simd_test(enable = "sse2")]
3583 const fn test_mm_sub_epi8() {
3584 let (a, b) = (_mm_set1_epi8(5), _mm_set1_epi8(6));
3585 let r = _mm_sub_epi8(a, b);
3586 assert_eq_m128i(r, _mm_set1_epi8(-1));
3587 }
3588
3589 #[simd_test(enable = "sse2")]
3590 const fn test_mm_sub_epi16() {
3591 let (a, b) = (_mm_set1_epi16(5), _mm_set1_epi16(6));
3592 let r = _mm_sub_epi16(a, b);
3593 assert_eq_m128i(r, _mm_set1_epi16(-1));
3594 }
3595
3596 #[simd_test(enable = "sse2")]
3597 const fn test_mm_sub_epi32() {
3598 let (a, b) = (_mm_set1_epi32(5), _mm_set1_epi32(6));
3599 let r = _mm_sub_epi32(a, b);
3600 assert_eq_m128i(r, _mm_set1_epi32(-1));
3601 }
3602
3603 #[simd_test(enable = "sse2")]
3604 const fn test_mm_sub_epi64() {
3605 let (a, b) = (_mm_set1_epi64x(5), _mm_set1_epi64x(6));
3606 let r = _mm_sub_epi64(a, b);
3607 assert_eq_m128i(r, _mm_set1_epi64x(-1));
3608 }
3609
3610 #[simd_test(enable = "sse2")]
3611 const fn test_mm_subs_epi8() {
3612 let (a, b) = (_mm_set1_epi8(5), _mm_set1_epi8(2));
3613 let r = _mm_subs_epi8(a, b);
3614 assert_eq_m128i(r, _mm_set1_epi8(3));
3615 }
3616
3617 #[simd_test(enable = "sse2")]
3618 fn test_mm_subs_epi8_saturate_positive() {
3619 let a = _mm_set1_epi8(0x7F);
3620 let b = _mm_set1_epi8(-1);
3621 let r = _mm_subs_epi8(a, b);
3622 assert_eq_m128i(r, a);
3623 }
3624
3625 #[simd_test(enable = "sse2")]
3626 fn test_mm_subs_epi8_saturate_negative() {
3627 let a = _mm_set1_epi8(-0x80);
3628 let b = _mm_set1_epi8(1);
3629 let r = _mm_subs_epi8(a, b);
3630 assert_eq_m128i(r, a);
3631 }
3632
3633 #[simd_test(enable = "sse2")]
3634 const fn test_mm_subs_epi16() {
3635 let (a, b) = (_mm_set1_epi16(5), _mm_set1_epi16(2));
3636 let r = _mm_subs_epi16(a, b);
3637 assert_eq_m128i(r, _mm_set1_epi16(3));
3638 }
3639
3640 #[simd_test(enable = "sse2")]
3641 fn test_mm_subs_epi16_saturate_positive() {
3642 let a = _mm_set1_epi16(0x7FFF);
3643 let b = _mm_set1_epi16(-1);
3644 let r = _mm_subs_epi16(a, b);
3645 assert_eq_m128i(r, a);
3646 }
3647
3648 #[simd_test(enable = "sse2")]
3649 fn test_mm_subs_epi16_saturate_negative() {
3650 let a = _mm_set1_epi16(-0x8000);
3651 let b = _mm_set1_epi16(1);
3652 let r = _mm_subs_epi16(a, b);
3653 assert_eq_m128i(r, a);
3654 }
3655
3656 #[simd_test(enable = "sse2")]
3657 const fn test_mm_subs_epu8() {
3658 let (a, b) = (_mm_set1_epi8(5), _mm_set1_epi8(2));
3659 let r = _mm_subs_epu8(a, b);
3660 assert_eq_m128i(r, _mm_set1_epi8(3));
3661 }
3662
3663 #[simd_test(enable = "sse2")]
3664 fn test_mm_subs_epu8_saturate() {
3665 let a = _mm_set1_epi8(0);
3666 let b = _mm_set1_epi8(1);
3667 let r = _mm_subs_epu8(a, b);
3668 assert_eq_m128i(r, a);
3669 }
3670
3671 #[simd_test(enable = "sse2")]
3672 const fn test_mm_subs_epu16() {
3673 let (a, b) = (_mm_set1_epi16(5), _mm_set1_epi16(2));
3674 let r = _mm_subs_epu16(a, b);
3675 assert_eq_m128i(r, _mm_set1_epi16(3));
3676 }
3677
3678 #[simd_test(enable = "sse2")]
3679 fn test_mm_subs_epu16_saturate() {
3680 let a = _mm_set1_epi16(0);
3681 let b = _mm_set1_epi16(1);
3682 let r = _mm_subs_epu16(a, b);
3683 assert_eq_m128i(r, a);
3684 }
3685
3686 #[simd_test(enable = "sse2")]
3687 const fn test_mm_slli_si128() {
3688 #[rustfmt::skip]
3689 let a = _mm_setr_epi8(
3690 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
3691 );
3692 let r = _mm_slli_si128::<1>(a);
3693 let e = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
3694 assert_eq_m128i(r, e);
3695
3696 #[rustfmt::skip]
3697 let a = _mm_setr_epi8(
3698 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
3699 );
3700 let r = _mm_slli_si128::<15>(a);
3701 let e = _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
3702 assert_eq_m128i(r, e);
3703
3704 #[rustfmt::skip]
3705 let a = _mm_setr_epi8(
3706 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
3707 );
3708 let r = _mm_slli_si128::<16>(a);
3709 assert_eq_m128i(r, _mm_set1_epi8(0));
3710 }
3711
3712 #[simd_test(enable = "sse2")]
3713 const fn test_mm_slli_epi16() {
3714 let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF);
3715 let r = _mm_slli_epi16::<4>(a);
3716 assert_eq_m128i(
3717 r,
3718 _mm_setr_epi16(0xCC0, -0xCC0, 0xDD0, -0xDD0, 0xEE0, -0xEE0, 0xFF0, -0xFF0),
3719 );
3720 let r = _mm_slli_epi16::<16>(a);
3721 assert_eq_m128i(r, _mm_set1_epi16(0));
3722 }
3723
3724 #[simd_test(enable = "sse2")]
3725 fn test_mm_sll_epi16() {
3726 let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF);
3727 let r = _mm_sll_epi16(a, _mm_set_epi64x(0, 4));
3728 assert_eq_m128i(
3729 r,
3730 _mm_setr_epi16(0xCC0, -0xCC0, 0xDD0, -0xDD0, 0xEE0, -0xEE0, 0xFF0, -0xFF0),
3731 );
3732 let r = _mm_sll_epi16(a, _mm_set_epi64x(4, 0));
3733 assert_eq_m128i(r, a);
3734 let r = _mm_sll_epi16(a, _mm_set_epi64x(0, 16));
3735 assert_eq_m128i(r, _mm_set1_epi16(0));
3736 let r = _mm_sll_epi16(a, _mm_set_epi64x(0, i64::MAX));
3737 assert_eq_m128i(r, _mm_set1_epi16(0));
3738 }
3739
3740 #[simd_test(enable = "sse2")]
3741 const fn test_mm_slli_epi32() {
3742 let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF);
3743 let r = _mm_slli_epi32::<4>(a);
3744 assert_eq_m128i(r, _mm_setr_epi32(0xEEEE0, -0xEEEE0, 0xFFFF0, -0xFFFF0));
3745 let r = _mm_slli_epi32::<32>(a);
3746 assert_eq_m128i(r, _mm_set1_epi32(0));
3747 }
3748
3749 #[simd_test(enable = "sse2")]
3750 fn test_mm_sll_epi32() {
3751 let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF);
3752 let r = _mm_sll_epi32(a, _mm_set_epi64x(0, 4));
3753 assert_eq_m128i(r, _mm_setr_epi32(0xEEEE0, -0xEEEE0, 0xFFFF0, -0xFFFF0));
3754 let r = _mm_sll_epi32(a, _mm_set_epi64x(4, 0));
3755 assert_eq_m128i(r, a);
3756 let r = _mm_sll_epi32(a, _mm_set_epi64x(0, 32));
3757 assert_eq_m128i(r, _mm_set1_epi32(0));
3758 let r = _mm_sll_epi32(a, _mm_set_epi64x(0, i64::MAX));
3759 assert_eq_m128i(r, _mm_set1_epi32(0));
3760 }
3761
3762 #[simd_test(enable = "sse2")]
3763 const fn test_mm_slli_epi64() {
3764 let a = _mm_set_epi64x(0xFFFFFFFF, -0xFFFFFFFF);
3765 let r = _mm_slli_epi64::<4>(a);
3766 assert_eq_m128i(r, _mm_set_epi64x(0xFFFFFFFF0, -0xFFFFFFFF0));
3767 let r = _mm_slli_epi64::<64>(a);
3768 assert_eq_m128i(r, _mm_set1_epi64x(0));
3769 }
3770
3771 #[simd_test(enable = "sse2")]
3772 fn test_mm_sll_epi64() {
3773 let a = _mm_set_epi64x(0xFFFFFFFF, -0xFFFFFFFF);
3774 let r = _mm_sll_epi64(a, _mm_set_epi64x(0, 4));
3775 assert_eq_m128i(r, _mm_set_epi64x(0xFFFFFFFF0, -0xFFFFFFFF0));
3776 let r = _mm_sll_epi64(a, _mm_set_epi64x(4, 0));
3777 assert_eq_m128i(r, a);
3778 let r = _mm_sll_epi64(a, _mm_set_epi64x(0, 64));
3779 assert_eq_m128i(r, _mm_set1_epi64x(0));
3780 let r = _mm_sll_epi64(a, _mm_set_epi64x(0, i64::MAX));
3781 assert_eq_m128i(r, _mm_set1_epi64x(0));
3782 }
3783
3784 #[simd_test(enable = "sse2")]
3785 const fn test_mm_srai_epi16() {
3786 let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF);
3787 let r = _mm_srai_epi16::<4>(a);
3788 assert_eq_m128i(
3789 r,
3790 _mm_setr_epi16(0xC, -0xD, 0xD, -0xE, 0xE, -0xF, 0xF, -0x10),
3791 );
3792 let r = _mm_srai_epi16::<16>(a);
3793 assert_eq_m128i(r, _mm_setr_epi16(0, -1, 0, -1, 0, -1, 0, -1));
3794 }
3795
3796 #[simd_test(enable = "sse2")]
3797 fn test_mm_sra_epi16() {
3798 let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF);
3799 let r = _mm_sra_epi16(a, _mm_set_epi64x(0, 4));
3800 assert_eq_m128i(
3801 r,
3802 _mm_setr_epi16(0xC, -0xD, 0xD, -0xE, 0xE, -0xF, 0xF, -0x10),
3803 );
3804 let r = _mm_sra_epi16(a, _mm_set_epi64x(4, 0));
3805 assert_eq_m128i(r, a);
3806 let r = _mm_sra_epi16(a, _mm_set_epi64x(0, 16));
3807 assert_eq_m128i(r, _mm_setr_epi16(0, -1, 0, -1, 0, -1, 0, -1));
3808 let r = _mm_sra_epi16(a, _mm_set_epi64x(0, i64::MAX));
3809 assert_eq_m128i(r, _mm_setr_epi16(0, -1, 0, -1, 0, -1, 0, -1));
3810 }
3811
3812 #[simd_test(enable = "sse2")]
3813 const fn test_mm_srai_epi32() {
3814 let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF);
3815 let r = _mm_srai_epi32::<4>(a);
3816 assert_eq_m128i(r, _mm_setr_epi32(0xEEE, -0xEEF, 0xFFF, -0x1000));
3817 let r = _mm_srai_epi32::<32>(a);
3818 assert_eq_m128i(r, _mm_setr_epi32(0, -1, 0, -1));
3819 }
3820
3821 #[simd_test(enable = "sse2")]
3822 fn test_mm_sra_epi32() {
3823 let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF);
3824 let r = _mm_sra_epi32(a, _mm_set_epi64x(0, 4));
3825 assert_eq_m128i(r, _mm_setr_epi32(0xEEE, -0xEEF, 0xFFF, -0x1000));
3826 let r = _mm_sra_epi32(a, _mm_set_epi64x(4, 0));
3827 assert_eq_m128i(r, a);
3828 let r = _mm_sra_epi32(a, _mm_set_epi64x(0, 32));
3829 assert_eq_m128i(r, _mm_setr_epi32(0, -1, 0, -1));
3830 let r = _mm_sra_epi32(a, _mm_set_epi64x(0, i64::MAX));
3831 assert_eq_m128i(r, _mm_setr_epi32(0, -1, 0, -1));
3832 }
3833
3834 #[simd_test(enable = "sse2")]
3835 const fn test_mm_srli_si128() {
3836 #[rustfmt::skip]
3837 let a = _mm_setr_epi8(
3838 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
3839 );
3840 let r = _mm_srli_si128::<1>(a);
3841 #[rustfmt::skip]
3842 let e = _mm_setr_epi8(
3843 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0,
3844 );
3845 assert_eq_m128i(r, e);
3846
3847 #[rustfmt::skip]
3848 let a = _mm_setr_epi8(
3849 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
3850 );
3851 let r = _mm_srli_si128::<15>(a);
3852 let e = _mm_setr_epi8(16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
3853 assert_eq_m128i(r, e);
3854
3855 #[rustfmt::skip]
3856 let a = _mm_setr_epi8(
3857 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
3858 );
3859 let r = _mm_srli_si128::<16>(a);
3860 assert_eq_m128i(r, _mm_set1_epi8(0));
3861 }
3862
3863 #[simd_test(enable = "sse2")]
3864 const fn test_mm_srli_epi16() {
3865 let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF);
3866 let r = _mm_srli_epi16::<4>(a);
3867 assert_eq_m128i(
3868 r,
3869 _mm_setr_epi16(0xC, 0xFF3, 0xD, 0xFF2, 0xE, 0xFF1, 0xF, 0xFF0),
3870 );
3871 let r = _mm_srli_epi16::<16>(a);
3872 assert_eq_m128i(r, _mm_set1_epi16(0));
3873 }
3874
3875 #[simd_test(enable = "sse2")]
3876 fn test_mm_srl_epi16() {
3877 let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF);
3878 let r = _mm_srl_epi16(a, _mm_set_epi64x(0, 4));
3879 assert_eq_m128i(
3880 r,
3881 _mm_setr_epi16(0xC, 0xFF3, 0xD, 0xFF2, 0xE, 0xFF1, 0xF, 0xFF0),
3882 );
3883 let r = _mm_srl_epi16(a, _mm_set_epi64x(4, 0));
3884 assert_eq_m128i(r, a);
3885 let r = _mm_srl_epi16(a, _mm_set_epi64x(0, 16));
3886 assert_eq_m128i(r, _mm_set1_epi16(0));
3887 let r = _mm_srl_epi16(a, _mm_set_epi64x(0, i64::MAX));
3888 assert_eq_m128i(r, _mm_set1_epi16(0));
3889 }
3890
3891 #[simd_test(enable = "sse2")]
3892 const fn test_mm_srli_epi32() {
3893 let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF);
3894 let r = _mm_srli_epi32::<4>(a);
3895 assert_eq_m128i(r, _mm_setr_epi32(0xEEE, 0xFFFF111, 0xFFF, 0xFFFF000));
3896 let r = _mm_srli_epi32::<32>(a);
3897 assert_eq_m128i(r, _mm_set1_epi32(0));
3898 }
3899
3900 #[simd_test(enable = "sse2")]
3901 fn test_mm_srl_epi32() {
3902 let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF);
3903 let r = _mm_srl_epi32(a, _mm_set_epi64x(0, 4));
3904 assert_eq_m128i(r, _mm_setr_epi32(0xEEE, 0xFFFF111, 0xFFF, 0xFFFF000));
3905 let r = _mm_srl_epi32(a, _mm_set_epi64x(4, 0));
3906 assert_eq_m128i(r, a);
3907 let r = _mm_srl_epi32(a, _mm_set_epi64x(0, 32));
3908 assert_eq_m128i(r, _mm_set1_epi32(0));
3909 let r = _mm_srl_epi32(a, _mm_set_epi64x(0, i64::MAX));
3910 assert_eq_m128i(r, _mm_set1_epi32(0));
3911 }
3912
3913 #[simd_test(enable = "sse2")]
3914 const fn test_mm_srli_epi64() {
3915 let a = _mm_set_epi64x(0xFFFFFFFF, -0xFFFFFFFF);
3916 let r = _mm_srli_epi64::<4>(a);
3917 assert_eq_m128i(r, _mm_set_epi64x(0xFFFFFFF, 0xFFFFFFFF0000000));
3918 let r = _mm_srli_epi64::<64>(a);
3919 assert_eq_m128i(r, _mm_set1_epi64x(0));
3920 }
3921
3922 #[simd_test(enable = "sse2")]
3923 fn test_mm_srl_epi64() {
3924 let a = _mm_set_epi64x(0xFFFFFFFF, -0xFFFFFFFF);
3925 let r = _mm_srl_epi64(a, _mm_set_epi64x(0, 4));
3926 assert_eq_m128i(r, _mm_set_epi64x(0xFFFFFFF, 0xFFFFFFFF0000000));
3927 let r = _mm_srl_epi64(a, _mm_set_epi64x(4, 0));
3928 assert_eq_m128i(r, a);
3929 let r = _mm_srl_epi64(a, _mm_set_epi64x(0, 64));
3930 assert_eq_m128i(r, _mm_set1_epi64x(0));
3931 let r = _mm_srl_epi64(a, _mm_set_epi64x(0, i64::MAX));
3932 assert_eq_m128i(r, _mm_set1_epi64x(0));
3933 }
3934
3935 #[simd_test(enable = "sse2")]
3936 const fn test_mm_and_si128() {
3937 let a = _mm_set1_epi8(5);
3938 let b = _mm_set1_epi8(3);
3939 let r = _mm_and_si128(a, b);
3940 assert_eq_m128i(r, _mm_set1_epi8(1));
3941 }
3942
3943 #[simd_test(enable = "sse2")]
3944 const fn test_mm_andnot_si128() {
3945 let a = _mm_set1_epi8(5);
3946 let b = _mm_set1_epi8(3);
3947 let r = _mm_andnot_si128(a, b);
3948 assert_eq_m128i(r, _mm_set1_epi8(2));
3949 }
3950
3951 #[simd_test(enable = "sse2")]
3952 const fn test_mm_or_si128() {
3953 let a = _mm_set1_epi8(5);
3954 let b = _mm_set1_epi8(3);
3955 let r = _mm_or_si128(a, b);
3956 assert_eq_m128i(r, _mm_set1_epi8(7));
3957 }
3958
3959 #[simd_test(enable = "sse2")]
3960 const fn test_mm_xor_si128() {
3961 let a = _mm_set1_epi8(5);
3962 let b = _mm_set1_epi8(3);
3963 let r = _mm_xor_si128(a, b);
3964 assert_eq_m128i(r, _mm_set1_epi8(6));
3965 }
3966
3967 #[simd_test(enable = "sse2")]
3968 const fn test_mm_cmpeq_epi8() {
3969 let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
3970 let b = _mm_setr_epi8(15, 14, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
3971 let r = _mm_cmpeq_epi8(a, b);
3972 #[rustfmt::skip]
3973 assert_eq_m128i(
3974 r,
3975 _mm_setr_epi8(
3976 0, 0, 0xFFu8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
3977 )
3978 );
3979 }
3980
3981 #[simd_test(enable = "sse2")]
3982 const fn test_mm_cmpeq_epi16() {
3983 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
3984 let b = _mm_setr_epi16(7, 6, 2, 4, 3, 2, 1, 0);
3985 let r = _mm_cmpeq_epi16(a, b);
3986 assert_eq_m128i(r, _mm_setr_epi16(0, 0, !0, 0, 0, 0, 0, 0));
3987 }
3988
3989 #[simd_test(enable = "sse2")]
3990 const fn test_mm_cmpeq_epi32() {
3991 let a = _mm_setr_epi32(0, 1, 2, 3);
3992 let b = _mm_setr_epi32(3, 2, 2, 0);
3993 let r = _mm_cmpeq_epi32(a, b);
3994 assert_eq_m128i(r, _mm_setr_epi32(0, 0, !0, 0));
3995 }
3996
3997 #[simd_test(enable = "sse2")]
3998 const fn test_mm_cmpgt_epi8() {
3999 let a = _mm_set_epi8(5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4000 let b = _mm_set1_epi8(0);
4001 let r = _mm_cmpgt_epi8(a, b);
4002 let e = _mm_set_epi8(!0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4003 assert_eq_m128i(r, e);
4004 }
4005
4006 #[simd_test(enable = "sse2")]
4007 const fn test_mm_cmpgt_epi16() {
4008 let a = _mm_set_epi16(5, 0, 0, 0, 0, 0, 0, 0);
4009 let b = _mm_set1_epi16(0);
4010 let r = _mm_cmpgt_epi16(a, b);
4011 let e = _mm_set_epi16(!0, 0, 0, 0, 0, 0, 0, 0);
4012 assert_eq_m128i(r, e);
4013 }
4014
4015 #[simd_test(enable = "sse2")]
4016 const fn test_mm_cmpgt_epi32() {
4017 let a = _mm_set_epi32(5, 0, 0, 0);
4018 let b = _mm_set1_epi32(0);
4019 let r = _mm_cmpgt_epi32(a, b);
4020 assert_eq_m128i(r, _mm_set_epi32(!0, 0, 0, 0));
4021 }
4022
4023 #[simd_test(enable = "sse2")]
4024 const fn test_mm_cmplt_epi8() {
4025 let a = _mm_set1_epi8(0);
4026 let b = _mm_set_epi8(5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4027 let r = _mm_cmplt_epi8(a, b);
4028 let e = _mm_set_epi8(!0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4029 assert_eq_m128i(r, e);
4030 }
4031
4032 #[simd_test(enable = "sse2")]
4033 const fn test_mm_cmplt_epi16() {
4034 let a = _mm_set1_epi16(0);
4035 let b = _mm_set_epi16(5, 0, 0, 0, 0, 0, 0, 0);
4036 let r = _mm_cmplt_epi16(a, b);
4037 let e = _mm_set_epi16(!0, 0, 0, 0, 0, 0, 0, 0);
4038 assert_eq_m128i(r, e);
4039 }
4040
4041 #[simd_test(enable = "sse2")]
4042 const fn test_mm_cmplt_epi32() {
4043 let a = _mm_set1_epi32(0);
4044 let b = _mm_set_epi32(5, 0, 0, 0);
4045 let r = _mm_cmplt_epi32(a, b);
4046 assert_eq_m128i(r, _mm_set_epi32(!0, 0, 0, 0));
4047 }
4048
4049 #[simd_test(enable = "sse2")]
4050 const fn test_mm_cvtepi32_pd() {
4051 let a = _mm_set_epi32(35, 25, 15, 5);
4052 let r = _mm_cvtepi32_pd(a);
4053 assert_eq_m128d(r, _mm_setr_pd(5.0, 15.0));
4054 }
4055
4056 #[simd_test(enable = "sse2")]
4057 const fn test_mm_cvtsi32_sd() {
4058 let a = _mm_set1_pd(3.5);
4059 let r = _mm_cvtsi32_sd(a, 5);
4060 assert_eq_m128d(r, _mm_setr_pd(5.0, 3.5));
4061 }
4062
4063 #[simd_test(enable = "sse2")]
4064 const fn test_mm_cvtepi32_ps() {
4065 let a = _mm_setr_epi32(1, 2, 3, 4);
4066 let r = _mm_cvtepi32_ps(a);
4067 assert_eq_m128(r, _mm_setr_ps(1.0, 2.0, 3.0, 4.0));
4068 }
4069
4070 #[simd_test(enable = "sse2")]
4071 fn test_mm_cvtps_epi32() {
4072 let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0);
4073 let r = _mm_cvtps_epi32(a);
4074 assert_eq_m128i(r, _mm_setr_epi32(1, 2, 3, 4));
4075 }
4076
4077 #[simd_test(enable = "sse2")]
4078 const fn test_mm_cvtsi32_si128() {
4079 let r = _mm_cvtsi32_si128(5);
4080 assert_eq_m128i(r, _mm_setr_epi32(5, 0, 0, 0));
4081 }
4082
4083 #[simd_test(enable = "sse2")]
4084 const fn test_mm_cvtsi128_si32() {
4085 let r = _mm_cvtsi128_si32(_mm_setr_epi32(5, 0, 0, 0));
4086 assert_eq!(r, 5);
4087 }
4088
4089 #[simd_test(enable = "sse2")]
4090 const fn test_mm_set_epi64x() {
4091 let r = _mm_set_epi64x(0, 1);
4092 assert_eq_m128i(r, _mm_setr_epi64x(1, 0));
4093 }
4094
4095 #[simd_test(enable = "sse2")]
4096 const fn test_mm_set_epi32() {
4097 let r = _mm_set_epi32(0, 1, 2, 3);
4098 assert_eq_m128i(r, _mm_setr_epi32(3, 2, 1, 0));
4099 }
4100
4101 #[simd_test(enable = "sse2")]
4102 const fn test_mm_set_epi16() {
4103 let r = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7);
4104 assert_eq_m128i(r, _mm_setr_epi16(7, 6, 5, 4, 3, 2, 1, 0));
4105 }
4106
4107 #[simd_test(enable = "sse2")]
4108 const fn test_mm_set_epi8() {
4109 #[rustfmt::skip]
4110 let r = _mm_set_epi8(
4111 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
4112 );
4113 #[rustfmt::skip]
4114 let e = _mm_setr_epi8(
4115 15, 14, 13, 12, 11, 10, 9, 8,
4116 7, 6, 5, 4, 3, 2, 1, 0,
4117 );
4118 assert_eq_m128i(r, e);
4119 }
4120
4121 #[simd_test(enable = "sse2")]
4122 const fn test_mm_set1_epi64x() {
4123 let r = _mm_set1_epi64x(1);
4124 assert_eq_m128i(r, _mm_set1_epi64x(1));
4125 }
4126
4127 #[simd_test(enable = "sse2")]
4128 const fn test_mm_set1_epi32() {
4129 let r = _mm_set1_epi32(1);
4130 assert_eq_m128i(r, _mm_set1_epi32(1));
4131 }
4132
4133 #[simd_test(enable = "sse2")]
4134 const fn test_mm_set1_epi16() {
4135 let r = _mm_set1_epi16(1);
4136 assert_eq_m128i(r, _mm_set1_epi16(1));
4137 }
4138
4139 #[simd_test(enable = "sse2")]
4140 const fn test_mm_set1_epi8() {
4141 let r = _mm_set1_epi8(1);
4142 assert_eq_m128i(r, _mm_set1_epi8(1));
4143 }
4144
4145 #[simd_test(enable = "sse2")]
4146 const fn test_mm_setr_epi32() {
4147 let r = _mm_setr_epi32(0, 1, 2, 3);
4148 assert_eq_m128i(r, _mm_setr_epi32(0, 1, 2, 3));
4149 }
4150
4151 #[simd_test(enable = "sse2")]
4152 const fn test_mm_setr_epi16() {
4153 let r = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
4154 assert_eq_m128i(r, _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7));
4155 }
4156
4157 #[simd_test(enable = "sse2")]
4158 const fn test_mm_setr_epi8() {
4159 #[rustfmt::skip]
4160 let r = _mm_setr_epi8(
4161 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
4162 );
4163 #[rustfmt::skip]
4164 let e = _mm_setr_epi8(
4165 0, 1, 2, 3, 4, 5, 6, 7,
4166 8, 9, 10, 11, 12, 13, 14, 15,
4167 );
4168 assert_eq_m128i(r, e);
4169 }
4170
4171 #[simd_test(enable = "sse2")]
4172 const fn test_mm_setzero_si128() {
4173 let r = _mm_setzero_si128();
4174 assert_eq_m128i(r, _mm_set1_epi64x(0));
4175 }
4176
4177 #[simd_test(enable = "sse2")]
4178 const fn test_mm_loadl_epi64() {
4179 let a = _mm_setr_epi64x(6, 5);
4180 let r = unsafe { _mm_loadl_epi64(ptr::addr_of!(a)) };
4181 assert_eq_m128i(r, _mm_setr_epi64x(6, 0));
4182 }
4183
4184 #[simd_test(enable = "sse2")]
4185 const fn test_mm_load_si128() {
4186 let a = _mm_set_epi64x(5, 6);
4187 let r = unsafe { _mm_load_si128(ptr::addr_of!(a) as *const _) };
4188 assert_eq_m128i(a, r);
4189 }
4190
4191 #[simd_test(enable = "sse2")]
4192 const fn test_mm_loadu_si128() {
4193 let a = _mm_set_epi64x(5, 6);
4194 let r = unsafe { _mm_loadu_si128(ptr::addr_of!(a) as *const _) };
4195 assert_eq_m128i(a, r);
4196 }
4197
4198 #[simd_test(enable = "sse2")]
4199 #[cfg_attr(miri, ignore)]
4202 fn test_mm_maskmoveu_si128() {
4203 let a = _mm_set1_epi8(9);
4204 #[rustfmt::skip]
4205 let mask = _mm_set_epi8(
4206 0, 0, 0x80u8 as i8, 0, 0, 0, 0, 0,
4207 0, 0, 0, 0, 0, 0, 0, 0,
4208 );
4209 let mut r = _mm_set1_epi8(0);
4210 unsafe {
4211 _mm_maskmoveu_si128(a, mask, ptr::addr_of_mut!(r) as *mut i8);
4212 }
4213 _mm_sfence();
4214 let e = _mm_set_epi8(0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4215 assert_eq_m128i(r, e);
4216 }
4217
4218 #[simd_test(enable = "sse2")]
4219 const fn test_mm_store_si128() {
4220 let a = _mm_set1_epi8(9);
4221 let mut r = _mm_set1_epi8(0);
4222 unsafe {
4223 _mm_store_si128(&mut r, a);
4224 }
4225 assert_eq_m128i(r, a);
4226 }
4227
4228 #[simd_test(enable = "sse2")]
4229 const fn test_mm_storeu_si128() {
4230 let a = _mm_set1_epi8(9);
4231 let mut r = _mm_set1_epi8(0);
4232 unsafe {
4233 _mm_storeu_si128(&mut r, a);
4234 }
4235 assert_eq_m128i(r, a);
4236 }
4237
4238 #[simd_test(enable = "sse2")]
4239 const fn test_mm_storel_epi64() {
4240 let a = _mm_setr_epi64x(2, 9);
4241 let mut r = _mm_set1_epi8(0);
4242 unsafe {
4243 _mm_storel_epi64(&mut r, a);
4244 }
4245 assert_eq_m128i(r, _mm_setr_epi64x(2, 0));
4246 }
4247
4248 #[simd_test(enable = "sse2")]
4249 #[cfg_attr(miri, ignore)]
4252 fn test_mm_stream_si128() {
4253 let a = _mm_setr_epi32(1, 2, 3, 4);
4254 let mut r = _mm_undefined_si128();
4255 unsafe {
4256 _mm_stream_si128(ptr::addr_of_mut!(r), a);
4257 }
4258 _mm_sfence();
4259 assert_eq_m128i(r, a);
4260 }
4261
4262 #[simd_test(enable = "sse2")]
4263 #[cfg_attr(miri, ignore)]
4266 fn test_mm_stream_si32() {
4267 let a: i32 = 7;
4268 let mut mem = boxed::Box::<i32>::new(-1);
4269 unsafe {
4270 _mm_stream_si32(ptr::addr_of_mut!(*mem), a);
4271 }
4272 _mm_sfence();
4273 assert_eq!(a, *mem);
4274 }
4275
4276 #[simd_test(enable = "sse2")]
4277 const fn test_mm_move_epi64() {
4278 let a = _mm_setr_epi64x(5, 6);
4279 let r = _mm_move_epi64(a);
4280 assert_eq_m128i(r, _mm_setr_epi64x(5, 0));
4281 }
4282
4283 #[simd_test(enable = "sse2")]
4284 fn test_mm_packs_epi16() {
4285 let a = _mm_setr_epi16(0x80, -0x81, 0, 0, 0, 0, 0, 0);
4286 let b = _mm_setr_epi16(0, 0, 0, 0, 0, 0, -0x81, 0x80);
4287 let r = _mm_packs_epi16(a, b);
4288 #[rustfmt::skip]
4289 assert_eq_m128i(
4290 r,
4291 _mm_setr_epi8(
4292 0x7F, -0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0x80, 0x7F
4293 )
4294 );
4295 }
4296
4297 #[simd_test(enable = "sse2")]
4298 fn test_mm_packs_epi32() {
4299 let a = _mm_setr_epi32(0x8000, -0x8001, 0, 0);
4300 let b = _mm_setr_epi32(0, 0, -0x8001, 0x8000);
4301 let r = _mm_packs_epi32(a, b);
4302 assert_eq_m128i(
4303 r,
4304 _mm_setr_epi16(0x7FFF, -0x8000, 0, 0, 0, 0, -0x8000, 0x7FFF),
4305 );
4306 }
4307
4308 #[simd_test(enable = "sse2")]
4309 fn test_mm_packus_epi16() {
4310 let a = _mm_setr_epi16(0x100, -1, 0, 0, 0, 0, 0, 0);
4311 let b = _mm_setr_epi16(0, 0, 0, 0, 0, 0, -1, 0x100);
4312 let r = _mm_packus_epi16(a, b);
4313 assert_eq_m128i(
4314 r,
4315 _mm_setr_epi8(!0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, !0),
4316 );
4317 }
4318
4319 #[simd_test(enable = "sse2")]
4320 const fn test_mm_extract_epi16() {
4321 let a = _mm_setr_epi16(-1, 1, 2, 3, 4, 5, 6, 7);
4322 let r1 = _mm_extract_epi16::<0>(a);
4323 let r2 = _mm_extract_epi16::<3>(a);
4324 assert_eq!(r1, 0xFFFF);
4325 assert_eq!(r2, 3);
4326 }
4327
4328 #[simd_test(enable = "sse2")]
4329 const fn test_mm_insert_epi16() {
4330 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
4331 let r = _mm_insert_epi16::<0>(a, 9);
4332 let e = _mm_setr_epi16(9, 1, 2, 3, 4, 5, 6, 7);
4333 assert_eq_m128i(r, e);
4334 }
4335
4336 #[simd_test(enable = "sse2")]
4337 const fn test_mm_movemask_epi8() {
4338 #[rustfmt::skip]
4339 let a = _mm_setr_epi8(
4340 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8, 0b01,
4341 0b0101, 0b1111_0000u8 as i8, 0, 0,
4342 0, 0b1011_0101u8 as i8, 0b1111_0000u8 as i8, 0b0101,
4343 0b01, 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8,
4344 );
4345 let r = _mm_movemask_epi8(a);
4346 assert_eq!(r, 0b10100110_00100101);
4347 }
4348
4349 #[simd_test(enable = "sse2")]
4350 const fn test_mm_shuffle_epi32() {
4351 let a = _mm_setr_epi32(5, 10, 15, 20);
4352 let r = _mm_shuffle_epi32::<0b00_01_01_11>(a);
4353 let e = _mm_setr_epi32(20, 10, 10, 5);
4354 assert_eq_m128i(r, e);
4355 }
4356
4357 #[simd_test(enable = "sse2")]
4358 const fn test_mm_shufflehi_epi16() {
4359 let a = _mm_setr_epi16(1, 2, 3, 4, 5, 10, 15, 20);
4360 let r = _mm_shufflehi_epi16::<0b00_01_01_11>(a);
4361 let e = _mm_setr_epi16(1, 2, 3, 4, 20, 10, 10, 5);
4362 assert_eq_m128i(r, e);
4363 }
4364
4365 #[simd_test(enable = "sse2")]
4366 const fn test_mm_shufflelo_epi16() {
4367 let a = _mm_setr_epi16(5, 10, 15, 20, 1, 2, 3, 4);
4368 let r = _mm_shufflelo_epi16::<0b00_01_01_11>(a);
4369 let e = _mm_setr_epi16(20, 10, 10, 5, 1, 2, 3, 4);
4370 assert_eq_m128i(r, e);
4371 }
4372
4373 #[simd_test(enable = "sse2")]
4374 const fn test_mm_unpackhi_epi8() {
4375 #[rustfmt::skip]
4376 let a = _mm_setr_epi8(
4377 0, 1, 2, 3, 4, 5, 6, 7,
4378 8, 9, 10, 11, 12, 13, 14, 15,
4379 );
4380 #[rustfmt::skip]
4381 let b = _mm_setr_epi8(
4382 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
4383 );
4384 let r = _mm_unpackhi_epi8(a, b);
4385 #[rustfmt::skip]
4386 let e = _mm_setr_epi8(
4387 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31,
4388 );
4389 assert_eq_m128i(r, e);
4390 }
4391
4392 #[simd_test(enable = "sse2")]
4393 const fn test_mm_unpackhi_epi16() {
4394 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
4395 let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15);
4396 let r = _mm_unpackhi_epi16(a, b);
4397 let e = _mm_setr_epi16(4, 12, 5, 13, 6, 14, 7, 15);
4398 assert_eq_m128i(r, e);
4399 }
4400
4401 #[simd_test(enable = "sse2")]
4402 const fn test_mm_unpackhi_epi32() {
4403 let a = _mm_setr_epi32(0, 1, 2, 3);
4404 let b = _mm_setr_epi32(4, 5, 6, 7);
4405 let r = _mm_unpackhi_epi32(a, b);
4406 let e = _mm_setr_epi32(2, 6, 3, 7);
4407 assert_eq_m128i(r, e);
4408 }
4409
4410 #[simd_test(enable = "sse2")]
4411 const fn test_mm_unpackhi_epi64() {
4412 let a = _mm_setr_epi64x(0, 1);
4413 let b = _mm_setr_epi64x(2, 3);
4414 let r = _mm_unpackhi_epi64(a, b);
4415 let e = _mm_setr_epi64x(1, 3);
4416 assert_eq_m128i(r, e);
4417 }
4418
4419 #[simd_test(enable = "sse2")]
4420 const fn test_mm_unpacklo_epi8() {
4421 #[rustfmt::skip]
4422 let a = _mm_setr_epi8(
4423 0, 1, 2, 3, 4, 5, 6, 7,
4424 8, 9, 10, 11, 12, 13, 14, 15,
4425 );
4426 #[rustfmt::skip]
4427 let b = _mm_setr_epi8(
4428 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
4429 );
4430 let r = _mm_unpacklo_epi8(a, b);
4431 #[rustfmt::skip]
4432 let e = _mm_setr_epi8(
4433 0, 16, 1, 17, 2, 18, 3, 19,
4434 4, 20, 5, 21, 6, 22, 7, 23,
4435 );
4436 assert_eq_m128i(r, e);
4437 }
4438
4439 #[simd_test(enable = "sse2")]
4440 const fn test_mm_unpacklo_epi16() {
4441 let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
4442 let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15);
4443 let r = _mm_unpacklo_epi16(a, b);
4444 let e = _mm_setr_epi16(0, 8, 1, 9, 2, 10, 3, 11);
4445 assert_eq_m128i(r, e);
4446 }
4447
4448 #[simd_test(enable = "sse2")]
4449 const fn test_mm_unpacklo_epi32() {
4450 let a = _mm_setr_epi32(0, 1, 2, 3);
4451 let b = _mm_setr_epi32(4, 5, 6, 7);
4452 let r = _mm_unpacklo_epi32(a, b);
4453 let e = _mm_setr_epi32(0, 4, 1, 5);
4454 assert_eq_m128i(r, e);
4455 }
4456
4457 #[simd_test(enable = "sse2")]
4458 const fn test_mm_unpacklo_epi64() {
4459 let a = _mm_setr_epi64x(0, 1);
4460 let b = _mm_setr_epi64x(2, 3);
4461 let r = _mm_unpacklo_epi64(a, b);
4462 let e = _mm_setr_epi64x(0, 2);
4463 assert_eq_m128i(r, e);
4464 }
4465
4466 #[simd_test(enable = "sse2")]
4467 const fn test_mm_add_sd() {
4468 let a = _mm_setr_pd(1.0, 2.0);
4469 let b = _mm_setr_pd(5.0, 10.0);
4470 let r = _mm_add_sd(a, b);
4471 assert_eq_m128d(r, _mm_setr_pd(6.0, 2.0));
4472 }
4473
4474 #[simd_test(enable = "sse2")]
4475 const fn test_mm_add_pd() {
4476 let a = _mm_setr_pd(1.0, 2.0);
4477 let b = _mm_setr_pd(5.0, 10.0);
4478 let r = _mm_add_pd(a, b);
4479 assert_eq_m128d(r, _mm_setr_pd(6.0, 12.0));
4480 }
4481
4482 #[simd_test(enable = "sse2")]
4483 const fn test_mm_div_sd() {
4484 let a = _mm_setr_pd(1.0, 2.0);
4485 let b = _mm_setr_pd(5.0, 10.0);
4486 let r = _mm_div_sd(a, b);
4487 assert_eq_m128d(r, _mm_setr_pd(0.2, 2.0));
4488 }
4489
4490 #[simd_test(enable = "sse2")]
4491 const fn test_mm_div_pd() {
4492 let a = _mm_setr_pd(1.0, 2.0);
4493 let b = _mm_setr_pd(5.0, 10.0);
4494 let r = _mm_div_pd(a, b);
4495 assert_eq_m128d(r, _mm_setr_pd(0.2, 0.2));
4496 }
4497
4498 #[simd_test(enable = "sse2")]
4499 fn test_mm_max_sd() {
4500 let a = _mm_setr_pd(1.0, 2.0);
4501 let b = _mm_setr_pd(5.0, 10.0);
4502 let r = _mm_max_sd(a, b);
4503 assert_eq_m128d(r, _mm_setr_pd(5.0, 2.0));
4504 }
4505
4506 #[simd_test(enable = "sse2")]
4507 fn test_mm_max_pd() {
4508 let a = _mm_setr_pd(1.0, 2.0);
4509 let b = _mm_setr_pd(5.0, 10.0);
4510 let r = _mm_max_pd(a, b);
4511 assert_eq_m128d(r, _mm_setr_pd(5.0, 10.0));
4512
4513 let a = _mm_setr_pd(-0.0, 0.0);
4515 let b = _mm_setr_pd(0.0, 0.0);
4516 let r1 = _mm_castpd_si128(_mm_max_pd(a, b));
4518 let r2 = _mm_castpd_si128(_mm_max_pd(b, a));
4519 let a = _mm_castpd_si128(a);
4520 let b = _mm_castpd_si128(b);
4521 assert_eq_m128i(r1, b);
4522 assert_eq_m128i(r2, a);
4523 assert_ne!(a.as_u8x16(), b.as_u8x16()); }
4525
4526 #[simd_test(enable = "sse2")]
4527 fn test_mm_min_sd() {
4528 let a = _mm_setr_pd(1.0, 2.0);
4529 let b = _mm_setr_pd(5.0, 10.0);
4530 let r = _mm_min_sd(a, b);
4531 assert_eq_m128d(r, _mm_setr_pd(1.0, 2.0));
4532 }
4533
4534 #[simd_test(enable = "sse2")]
4535 fn test_mm_min_pd() {
4536 let a = _mm_setr_pd(1.0, 2.0);
4537 let b = _mm_setr_pd(5.0, 10.0);
4538 let r = _mm_min_pd(a, b);
4539 assert_eq_m128d(r, _mm_setr_pd(1.0, 2.0));
4540
4541 let a = _mm_setr_pd(-0.0, 0.0);
4543 let b = _mm_setr_pd(0.0, 0.0);
4544 let r1 = _mm_castpd_si128(_mm_min_pd(a, b));
4546 let r2 = _mm_castpd_si128(_mm_min_pd(b, a));
4547 let a = _mm_castpd_si128(a);
4548 let b = _mm_castpd_si128(b);
4549 assert_eq_m128i(r1, b);
4550 assert_eq_m128i(r2, a);
4551 assert_ne!(a.as_u8x16(), b.as_u8x16()); }
4553
4554 #[simd_test(enable = "sse2")]
4555 const fn test_mm_mul_sd() {
4556 let a = _mm_setr_pd(1.0, 2.0);
4557 let b = _mm_setr_pd(5.0, 10.0);
4558 let r = _mm_mul_sd(a, b);
4559 assert_eq_m128d(r, _mm_setr_pd(5.0, 2.0));
4560 }
4561
4562 #[simd_test(enable = "sse2")]
4563 const fn test_mm_mul_pd() {
4564 let a = _mm_setr_pd(1.0, 2.0);
4565 let b = _mm_setr_pd(5.0, 10.0);
4566 let r = _mm_mul_pd(a, b);
4567 assert_eq_m128d(r, _mm_setr_pd(5.0, 20.0));
4568 }
4569
4570 #[simd_test(enable = "sse2")]
4571 fn test_mm_sqrt_sd() {
4572 let a = _mm_setr_pd(1.0, 2.0);
4573 let b = _mm_setr_pd(5.0, 10.0);
4574 let r = _mm_sqrt_sd(a, b);
4575 assert_eq_m128d(r, _mm_setr_pd(5.0f64.sqrt(), 2.0));
4576 }
4577
4578 #[simd_test(enable = "sse2")]
4579 fn test_mm_sqrt_pd() {
4580 let r = _mm_sqrt_pd(_mm_setr_pd(1.0, 2.0));
4581 assert_eq_m128d(r, _mm_setr_pd(1.0f64.sqrt(), 2.0f64.sqrt()));
4582 }
4583
4584 #[simd_test(enable = "sse2")]
4585 const fn test_mm_sub_sd() {
4586 let a = _mm_setr_pd(1.0, 2.0);
4587 let b = _mm_setr_pd(5.0, 10.0);
4588 let r = _mm_sub_sd(a, b);
4589 assert_eq_m128d(r, _mm_setr_pd(-4.0, 2.0));
4590 }
4591
4592 #[simd_test(enable = "sse2")]
4593 const fn test_mm_sub_pd() {
4594 let a = _mm_setr_pd(1.0, 2.0);
4595 let b = _mm_setr_pd(5.0, 10.0);
4596 let r = _mm_sub_pd(a, b);
4597 assert_eq_m128d(r, _mm_setr_pd(-4.0, -8.0));
4598 }
4599
4600 #[simd_test(enable = "sse2")]
4601 const fn test_mm_and_pd() {
4602 let a = f64x2::from_bits(u64x2::splat(5)).as_m128d();
4603 let b = f64x2::from_bits(u64x2::splat(3)).as_m128d();
4604 let r = _mm_and_pd(a, b);
4605 let e = f64x2::from_bits(u64x2::splat(1)).as_m128d();
4606 assert_eq_m128d(r, e);
4607 }
4608
4609 #[simd_test(enable = "sse2")]
4610 const fn test_mm_andnot_pd() {
4611 let a = f64x2::from_bits(u64x2::splat(5)).as_m128d();
4612 let b = f64x2::from_bits(u64x2::splat(3)).as_m128d();
4613 let r = _mm_andnot_pd(a, b);
4614 let e = f64x2::from_bits(u64x2::splat(2)).as_m128d();
4615 assert_eq_m128d(r, e);
4616 }
4617
4618 #[simd_test(enable = "sse2")]
4619 const fn test_mm_or_pd() {
4620 let a = f64x2::from_bits(u64x2::splat(5)).as_m128d();
4621 let b = f64x2::from_bits(u64x2::splat(3)).as_m128d();
4622 let r = _mm_or_pd(a, b);
4623 let e = f64x2::from_bits(u64x2::splat(7)).as_m128d();
4624 assert_eq_m128d(r, e);
4625 }
4626
4627 #[simd_test(enable = "sse2")]
4628 const fn test_mm_xor_pd() {
4629 let a = f64x2::from_bits(u64x2::splat(5)).as_m128d();
4630 let b = f64x2::from_bits(u64x2::splat(3)).as_m128d();
4631 let r = _mm_xor_pd(a, b);
4632 let e = f64x2::from_bits(u64x2::splat(6)).as_m128d();
4633 assert_eq_m128d(r, e);
4634 }
4635
4636 #[simd_test(enable = "sse2")]
4637 fn test_mm_cmpeq_sd() {
4638 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4639 let e = _mm_setr_epi64x(!0, 2.0f64.to_bits() as i64);
4640 let r = _mm_castpd_si128(_mm_cmpeq_sd(a, b));
4641 assert_eq_m128i(r, e);
4642 }
4643
4644 #[simd_test(enable = "sse2")]
4645 fn test_mm_cmplt_sd() {
4646 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(5.0, 3.0));
4647 let e = _mm_setr_epi64x(!0, 2.0f64.to_bits() as i64);
4648 let r = _mm_castpd_si128(_mm_cmplt_sd(a, b));
4649 assert_eq_m128i(r, e);
4650 }
4651
4652 #[simd_test(enable = "sse2")]
4653 fn test_mm_cmple_sd() {
4654 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4655 let e = _mm_setr_epi64x(!0, 2.0f64.to_bits() as i64);
4656 let r = _mm_castpd_si128(_mm_cmple_sd(a, b));
4657 assert_eq_m128i(r, e);
4658 }
4659
4660 #[simd_test(enable = "sse2")]
4661 fn test_mm_cmpgt_sd() {
4662 let (a, b) = (_mm_setr_pd(5.0, 2.0), _mm_setr_pd(1.0, 3.0));
4663 let e = _mm_setr_epi64x(!0, 2.0f64.to_bits() as i64);
4664 let r = _mm_castpd_si128(_mm_cmpgt_sd(a, b));
4665 assert_eq_m128i(r, e);
4666 }
4667
4668 #[simd_test(enable = "sse2")]
4669 fn test_mm_cmpge_sd() {
4670 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4671 let e = _mm_setr_epi64x(!0, 2.0f64.to_bits() as i64);
4672 let r = _mm_castpd_si128(_mm_cmpge_sd(a, b));
4673 assert_eq_m128i(r, e);
4674 }
4675
4676 #[simd_test(enable = "sse2")]
4677 fn test_mm_cmpord_sd() {
4678 let (a, b) = (_mm_setr_pd(NAN, 2.0), _mm_setr_pd(5.0, 3.0));
4679 let e = _mm_setr_epi64x(0, 2.0f64.to_bits() as i64);
4680 let r = _mm_castpd_si128(_mm_cmpord_sd(a, b));
4681 assert_eq_m128i(r, e);
4682 }
4683
4684 #[simd_test(enable = "sse2")]
4685 fn test_mm_cmpunord_sd() {
4686 let (a, b) = (_mm_setr_pd(NAN, 2.0), _mm_setr_pd(5.0, 3.0));
4687 let e = _mm_setr_epi64x(!0, 2.0f64.to_bits() as i64);
4688 let r = _mm_castpd_si128(_mm_cmpunord_sd(a, b));
4689 assert_eq_m128i(r, e);
4690 }
4691
4692 #[simd_test(enable = "sse2")]
4693 fn test_mm_cmpneq_sd() {
4694 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(5.0, 3.0));
4695 let e = _mm_setr_epi64x(!0, 2.0f64.to_bits() as i64);
4696 let r = _mm_castpd_si128(_mm_cmpneq_sd(a, b));
4697 assert_eq_m128i(r, e);
4698 }
4699
4700 #[simd_test(enable = "sse2")]
4701 fn test_mm_cmpnlt_sd() {
4702 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(5.0, 3.0));
4703 let e = _mm_setr_epi64x(0, 2.0f64.to_bits() as i64);
4704 let r = _mm_castpd_si128(_mm_cmpnlt_sd(a, b));
4705 assert_eq_m128i(r, e);
4706 }
4707
4708 #[simd_test(enable = "sse2")]
4709 fn test_mm_cmpnle_sd() {
4710 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4711 let e = _mm_setr_epi64x(0, 2.0f64.to_bits() as i64);
4712 let r = _mm_castpd_si128(_mm_cmpnle_sd(a, b));
4713 assert_eq_m128i(r, e);
4714 }
4715
4716 #[simd_test(enable = "sse2")]
4717 fn test_mm_cmpngt_sd() {
4718 let (a, b) = (_mm_setr_pd(5.0, 2.0), _mm_setr_pd(1.0, 3.0));
4719 let e = _mm_setr_epi64x(0, 2.0f64.to_bits() as i64);
4720 let r = _mm_castpd_si128(_mm_cmpngt_sd(a, b));
4721 assert_eq_m128i(r, e);
4722 }
4723
4724 #[simd_test(enable = "sse2")]
4725 fn test_mm_cmpnge_sd() {
4726 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4727 let e = _mm_setr_epi64x(0, 2.0f64.to_bits() as i64);
4728 let r = _mm_castpd_si128(_mm_cmpnge_sd(a, b));
4729 assert_eq_m128i(r, e);
4730 }
4731
4732 #[simd_test(enable = "sse2")]
4733 fn test_mm_cmpeq_pd() {
4734 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4735 let e = _mm_setr_epi64x(!0, 0);
4736 let r = _mm_castpd_si128(_mm_cmpeq_pd(a, b));
4737 assert_eq_m128i(r, e);
4738 }
4739
4740 #[simd_test(enable = "sse2")]
4741 fn test_mm_cmplt_pd() {
4742 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4743 let e = _mm_setr_epi64x(0, !0);
4744 let r = _mm_castpd_si128(_mm_cmplt_pd(a, b));
4745 assert_eq_m128i(r, e);
4746 }
4747
4748 #[simd_test(enable = "sse2")]
4749 fn test_mm_cmple_pd() {
4750 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4751 let e = _mm_setr_epi64x(!0, !0);
4752 let r = _mm_castpd_si128(_mm_cmple_pd(a, b));
4753 assert_eq_m128i(r, e);
4754 }
4755
4756 #[simd_test(enable = "sse2")]
4757 fn test_mm_cmpgt_pd() {
4758 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4759 let e = _mm_setr_epi64x(0, 0);
4760 let r = _mm_castpd_si128(_mm_cmpgt_pd(a, b));
4761 assert_eq_m128i(r, e);
4762 }
4763
4764 #[simd_test(enable = "sse2")]
4765 fn test_mm_cmpge_pd() {
4766 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4767 let e = _mm_setr_epi64x(!0, 0);
4768 let r = _mm_castpd_si128(_mm_cmpge_pd(a, b));
4769 assert_eq_m128i(r, e);
4770 }
4771
4772 #[simd_test(enable = "sse2")]
4773 fn test_mm_cmpord_pd() {
4774 let (a, b) = (_mm_setr_pd(NAN, 2.0), _mm_setr_pd(5.0, 3.0));
4775 let e = _mm_setr_epi64x(0, !0);
4776 let r = _mm_castpd_si128(_mm_cmpord_pd(a, b));
4777 assert_eq_m128i(r, e);
4778 }
4779
4780 #[simd_test(enable = "sse2")]
4781 fn test_mm_cmpunord_pd() {
4782 let (a, b) = (_mm_setr_pd(NAN, 2.0), _mm_setr_pd(5.0, 3.0));
4783 let e = _mm_setr_epi64x(!0, 0);
4784 let r = _mm_castpd_si128(_mm_cmpunord_pd(a, b));
4785 assert_eq_m128i(r, e);
4786 }
4787
4788 #[simd_test(enable = "sse2")]
4789 fn test_mm_cmpneq_pd() {
4790 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(5.0, 3.0));
4791 let e = _mm_setr_epi64x(!0, !0);
4792 let r = _mm_castpd_si128(_mm_cmpneq_pd(a, b));
4793 assert_eq_m128i(r, e);
4794 }
4795
4796 #[simd_test(enable = "sse2")]
4797 fn test_mm_cmpnlt_pd() {
4798 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(5.0, 3.0));
4799 let e = _mm_setr_epi64x(0, 0);
4800 let r = _mm_castpd_si128(_mm_cmpnlt_pd(a, b));
4801 assert_eq_m128i(r, e);
4802 }
4803
4804 #[simd_test(enable = "sse2")]
4805 fn test_mm_cmpnle_pd() {
4806 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4807 let e = _mm_setr_epi64x(0, 0);
4808 let r = _mm_castpd_si128(_mm_cmpnle_pd(a, b));
4809 assert_eq_m128i(r, e);
4810 }
4811
4812 #[simd_test(enable = "sse2")]
4813 fn test_mm_cmpngt_pd() {
4814 let (a, b) = (_mm_setr_pd(5.0, 2.0), _mm_setr_pd(1.0, 3.0));
4815 let e = _mm_setr_epi64x(0, !0);
4816 let r = _mm_castpd_si128(_mm_cmpngt_pd(a, b));
4817 assert_eq_m128i(r, e);
4818 }
4819
4820 #[simd_test(enable = "sse2")]
4821 fn test_mm_cmpnge_pd() {
4822 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4823 let e = _mm_setr_epi64x(0, !0);
4824 let r = _mm_castpd_si128(_mm_cmpnge_pd(a, b));
4825 assert_eq_m128i(r, e);
4826 }
4827
4828 #[simd_test(enable = "sse2")]
4829 fn test_mm_comieq_sd() {
4830 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4831 assert!(_mm_comieq_sd(a, b) != 0);
4832
4833 let (a, b) = (_mm_setr_pd(NAN, 2.0), _mm_setr_pd(1.0, 3.0));
4834 assert!(_mm_comieq_sd(a, b) == 0);
4835 }
4836
4837 #[simd_test(enable = "sse2")]
4838 fn test_mm_comilt_sd() {
4839 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4840 assert!(_mm_comilt_sd(a, b) == 0);
4841 }
4842
4843 #[simd_test(enable = "sse2")]
4844 fn test_mm_comile_sd() {
4845 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4846 assert!(_mm_comile_sd(a, b) != 0);
4847 }
4848
4849 #[simd_test(enable = "sse2")]
4850 fn test_mm_comigt_sd() {
4851 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4852 assert!(_mm_comigt_sd(a, b) == 0);
4853 }
4854
4855 #[simd_test(enable = "sse2")]
4856 fn test_mm_comige_sd() {
4857 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4858 assert!(_mm_comige_sd(a, b) != 0);
4859 }
4860
4861 #[simd_test(enable = "sse2")]
4862 fn test_mm_comineq_sd() {
4863 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4864 assert!(_mm_comineq_sd(a, b) == 0);
4865 }
4866
4867 #[simd_test(enable = "sse2")]
4868 fn test_mm_ucomieq_sd() {
4869 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4870 assert!(_mm_ucomieq_sd(a, b) != 0);
4871
4872 let (a, b) = (_mm_setr_pd(NAN, 2.0), _mm_setr_pd(NAN, 3.0));
4873 assert!(_mm_ucomieq_sd(a, b) == 0);
4874 }
4875
4876 #[simd_test(enable = "sse2")]
4877 fn test_mm_ucomilt_sd() {
4878 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4879 assert!(_mm_ucomilt_sd(a, b) == 0);
4880 }
4881
4882 #[simd_test(enable = "sse2")]
4883 fn test_mm_ucomile_sd() {
4884 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4885 assert!(_mm_ucomile_sd(a, b) != 0);
4886 }
4887
4888 #[simd_test(enable = "sse2")]
4889 fn test_mm_ucomigt_sd() {
4890 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4891 assert!(_mm_ucomigt_sd(a, b) == 0);
4892 }
4893
4894 #[simd_test(enable = "sse2")]
4895 fn test_mm_ucomige_sd() {
4896 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4897 assert!(_mm_ucomige_sd(a, b) != 0);
4898 }
4899
4900 #[simd_test(enable = "sse2")]
4901 fn test_mm_ucomineq_sd() {
4902 let (a, b) = (_mm_setr_pd(1.0, 2.0), _mm_setr_pd(1.0, 3.0));
4903 assert!(_mm_ucomineq_sd(a, b) == 0);
4904 }
4905
4906 #[simd_test(enable = "sse2")]
4907 const fn test_mm_movemask_pd() {
4908 let r = _mm_movemask_pd(_mm_setr_pd(-1.0, 5.0));
4909 assert_eq!(r, 0b01);
4910
4911 let r = _mm_movemask_pd(_mm_setr_pd(-1.0, -5.0));
4912 assert_eq!(r, 0b11);
4913 }
4914
4915 #[repr(align(16))]
4916 struct Memory {
4917 data: [f64; 4],
4918 }
4919
4920 #[simd_test(enable = "sse2")]
4921 const fn test_mm_load_pd() {
4922 let mem = Memory {
4923 data: [1.0f64, 2.0, 3.0, 4.0],
4924 };
4925 let vals = &mem.data;
4926 let d = vals.as_ptr();
4927
4928 let r = unsafe { _mm_load_pd(d) };
4929 assert_eq_m128d(r, _mm_setr_pd(1.0, 2.0));
4930 }
4931
4932 #[simd_test(enable = "sse2")]
4933 const fn test_mm_load_sd() {
4934 let a = 1.;
4935 let expected = _mm_setr_pd(a, 0.);
4936 let r = unsafe { _mm_load_sd(&a) };
4937 assert_eq_m128d(r, expected);
4938 }
4939
4940 #[simd_test(enable = "sse2")]
4941 const fn test_mm_loadh_pd() {
4942 let a = _mm_setr_pd(1., 2.);
4943 let b = 3.;
4944 let expected = _mm_setr_pd(_mm_cvtsd_f64(a), 3.);
4945 let r = unsafe { _mm_loadh_pd(a, &b) };
4946 assert_eq_m128d(r, expected);
4947 }
4948
4949 #[simd_test(enable = "sse2")]
4950 const fn test_mm_loadl_pd() {
4951 let a = _mm_setr_pd(1., 2.);
4952 let b = 3.;
4953 let expected = _mm_setr_pd(3., get_m128d(a, 1));
4954 let r = unsafe { _mm_loadl_pd(a, &b) };
4955 assert_eq_m128d(r, expected);
4956 }
4957
4958 #[simd_test(enable = "sse2")]
4959 #[cfg_attr(miri, ignore)]
4962 fn test_mm_stream_pd() {
4963 #[repr(align(128))]
4964 struct Memory {
4965 pub data: [f64; 2],
4966 }
4967 let a = _mm_set1_pd(7.0);
4968 let mut mem = Memory { data: [-1.0; 2] };
4969
4970 unsafe {
4971 _mm_stream_pd(ptr::addr_of_mut!(mem.data[0]), a);
4972 }
4973 _mm_sfence();
4974 for i in 0..2 {
4975 assert_eq!(mem.data[i], get_m128d(a, i));
4976 }
4977 }
4978
4979 #[simd_test(enable = "sse2")]
4980 const fn test_mm_store_sd() {
4981 let mut dest = 0.;
4982 let a = _mm_setr_pd(1., 2.);
4983 unsafe {
4984 _mm_store_sd(&mut dest, a);
4985 }
4986 assert_eq!(dest, _mm_cvtsd_f64(a));
4987 }
4988
4989 #[simd_test(enable = "sse2")]
4990 const fn test_mm_store_pd() {
4991 let mut mem = Memory { data: [0.0f64; 4] };
4992 let vals = &mut mem.data;
4993 let a = _mm_setr_pd(1.0, 2.0);
4994 let d = vals.as_mut_ptr();
4995
4996 unsafe {
4997 _mm_store_pd(d, *black_box(&a));
4998 }
4999 assert_eq!(vals[0], 1.0);
5000 assert_eq!(vals[1], 2.0);
5001 }
5002
5003 #[simd_test(enable = "sse2")]
5004 const fn test_mm_storeu_pd() {
5005 let mut mem = Memory { data: [0.0f64; 4] };
5007 let vals = &mut mem.data;
5008 let a = _mm_setr_pd(1.0, 2.0);
5009
5010 unsafe {
5012 let p = vals.as_mut_ptr().offset(1);
5013 _mm_storeu_pd(p, *black_box(&a));
5014 }
5015
5016 assert_eq!(*vals, [0.0, 1.0, 2.0, 0.0]);
5017 }
5018
5019 #[simd_test(enable = "sse2")]
5020 const fn test_mm_storeu_si16() {
5021 let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8);
5022 let mut r = _mm_setr_epi16(9, 10, 11, 12, 13, 14, 15, 16);
5023 unsafe {
5024 _mm_storeu_si16(ptr::addr_of_mut!(r).cast(), a);
5025 }
5026 let e = _mm_setr_epi16(1, 10, 11, 12, 13, 14, 15, 16);
5027 assert_eq_m128i(r, e);
5028 }
5029
5030 #[simd_test(enable = "sse2")]
5031 const fn test_mm_storeu_si32() {
5032 let a = _mm_setr_epi32(1, 2, 3, 4);
5033 let mut r = _mm_setr_epi32(5, 6, 7, 8);
5034 unsafe {
5035 _mm_storeu_si32(ptr::addr_of_mut!(r).cast(), a);
5036 }
5037 let e = _mm_setr_epi32(1, 6, 7, 8);
5038 assert_eq_m128i(r, e);
5039 }
5040
5041 #[simd_test(enable = "sse2")]
5042 const fn test_mm_storeu_si64() {
5043 let a = _mm_setr_epi64x(1, 2);
5044 let mut r = _mm_setr_epi64x(3, 4);
5045 unsafe {
5046 _mm_storeu_si64(ptr::addr_of_mut!(r).cast(), a);
5047 }
5048 let e = _mm_setr_epi64x(1, 4);
5049 assert_eq_m128i(r, e);
5050 }
5051
5052 #[simd_test(enable = "sse2")]
5053 const fn test_mm_store1_pd() {
5054 let mut mem = Memory { data: [0.0f64; 4] };
5055 let vals = &mut mem.data;
5056 let a = _mm_setr_pd(1.0, 2.0);
5057 let d = vals.as_mut_ptr();
5058
5059 unsafe {
5060 _mm_store1_pd(d, *black_box(&a));
5061 }
5062 assert_eq!(vals[0], 1.0);
5063 assert_eq!(vals[1], 1.0);
5064 }
5065
5066 #[simd_test(enable = "sse2")]
5067 const fn test_mm_store_pd1() {
5068 let mut mem = Memory { data: [0.0f64; 4] };
5069 let vals = &mut mem.data;
5070 let a = _mm_setr_pd(1.0, 2.0);
5071 let d = vals.as_mut_ptr();
5072
5073 unsafe {
5074 _mm_store_pd1(d, *black_box(&a));
5075 }
5076 assert_eq!(vals[0], 1.0);
5077 assert_eq!(vals[1], 1.0);
5078 }
5079
5080 #[simd_test(enable = "sse2")]
5081 const fn test_mm_storer_pd() {
5082 let mut mem = Memory { data: [0.0f64; 4] };
5083 let vals = &mut mem.data;
5084 let a = _mm_setr_pd(1.0, 2.0);
5085 let d = vals.as_mut_ptr();
5086
5087 unsafe {
5088 _mm_storer_pd(d, *black_box(&a));
5089 }
5090 assert_eq!(vals[0], 2.0);
5091 assert_eq!(vals[1], 1.0);
5092 }
5093
5094 #[simd_test(enable = "sse2")]
5095 const fn test_mm_storeh_pd() {
5096 let mut dest = 0.;
5097 let a = _mm_setr_pd(1., 2.);
5098 unsafe {
5099 _mm_storeh_pd(&mut dest, a);
5100 }
5101 assert_eq!(dest, get_m128d(a, 1));
5102 }
5103
5104 #[simd_test(enable = "sse2")]
5105 const fn test_mm_storel_pd() {
5106 let mut dest = 0.;
5107 let a = _mm_setr_pd(1., 2.);
5108 unsafe {
5109 _mm_storel_pd(&mut dest, a);
5110 }
5111 assert_eq!(dest, _mm_cvtsd_f64(a));
5112 }
5113
5114 #[simd_test(enable = "sse2")]
5115 const fn test_mm_loadr_pd() {
5116 let mut mem = Memory {
5117 data: [1.0f64, 2.0, 3.0, 4.0],
5118 };
5119 let vals = &mut mem.data;
5120 let d = vals.as_ptr();
5121
5122 let r = unsafe { _mm_loadr_pd(d) };
5123 assert_eq_m128d(r, _mm_setr_pd(2.0, 1.0));
5124 }
5125
5126 #[simd_test(enable = "sse2")]
5127 const fn test_mm_loadu_pd() {
5128 let mut mem = Memory {
5130 data: [1.0f64, 2.0, 3.0, 4.0],
5131 };
5132 let vals = &mut mem.data;
5133
5134 let d = unsafe { vals.as_ptr().offset(1) };
5136
5137 let r = unsafe { _mm_loadu_pd(d) };
5138 let e = _mm_setr_pd(2.0, 3.0);
5139 assert_eq_m128d(r, e);
5140 }
5141
5142 #[simd_test(enable = "sse2")]
5143 const fn test_mm_loadu_si16() {
5144 let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8);
5145 let r = unsafe { _mm_loadu_si16(ptr::addr_of!(a) as *const _) };
5146 assert_eq_m128i(r, _mm_setr_epi16(1, 0, 0, 0, 0, 0, 0, 0));
5147 }
5148
5149 #[simd_test(enable = "sse2")]
5150 const fn test_mm_loadu_si32() {
5151 let a = _mm_setr_epi32(1, 2, 3, 4);
5152 let r = unsafe { _mm_loadu_si32(ptr::addr_of!(a) as *const _) };
5153 assert_eq_m128i(r, _mm_setr_epi32(1, 0, 0, 0));
5154 }
5155
5156 #[simd_test(enable = "sse2")]
5157 const fn test_mm_loadu_si64() {
5158 let a = _mm_setr_epi64x(5, 6);
5159 let r = unsafe { _mm_loadu_si64(ptr::addr_of!(a) as *const _) };
5160 assert_eq_m128i(r, _mm_setr_epi64x(5, 0));
5161 }
5162
5163 #[simd_test(enable = "sse2")]
5164 const fn test_mm_cvtpd_ps() {
5165 let r = _mm_cvtpd_ps(_mm_setr_pd(-1.0, 5.0));
5166 assert_eq_m128(r, _mm_setr_ps(-1.0, 5.0, 0.0, 0.0));
5167
5168 let r = _mm_cvtpd_ps(_mm_setr_pd(-1.0, -5.0));
5169 assert_eq_m128(r, _mm_setr_ps(-1.0, -5.0, 0.0, 0.0));
5170
5171 let r = _mm_cvtpd_ps(_mm_setr_pd(f64::MAX, f64::MIN));
5172 assert_eq_m128(r, _mm_setr_ps(f32::INFINITY, f32::NEG_INFINITY, 0.0, 0.0));
5173
5174 let r = _mm_cvtpd_ps(_mm_setr_pd(f32::MAX as f64, f32::MIN as f64));
5175 assert_eq_m128(r, _mm_setr_ps(f32::MAX, f32::MIN, 0.0, 0.0));
5176 }
5177
5178 #[simd_test(enable = "sse2")]
5179 const fn test_mm_cvtps_pd() {
5180 let r = _mm_cvtps_pd(_mm_setr_ps(-1.0, 2.0, -3.0, 5.0));
5181 assert_eq_m128d(r, _mm_setr_pd(-1.0, 2.0));
5182
5183 let r = _mm_cvtps_pd(_mm_setr_ps(
5184 f32::MAX,
5185 f32::INFINITY,
5186 f32::NEG_INFINITY,
5187 f32::MIN,
5188 ));
5189 assert_eq_m128d(r, _mm_setr_pd(f32::MAX as f64, f64::INFINITY));
5190 }
5191
5192 #[simd_test(enable = "sse2")]
5193 fn test_mm_cvtpd_epi32() {
5194 let r = _mm_cvtpd_epi32(_mm_setr_pd(-1.0, 5.0));
5195 assert_eq_m128i(r, _mm_setr_epi32(-1, 5, 0, 0));
5196
5197 let r = _mm_cvtpd_epi32(_mm_setr_pd(-1.0, -5.0));
5198 assert_eq_m128i(r, _mm_setr_epi32(-1, -5, 0, 0));
5199
5200 let r = _mm_cvtpd_epi32(_mm_setr_pd(f64::MAX, f64::MIN));
5201 assert_eq_m128i(r, _mm_setr_epi32(i32::MIN, i32::MIN, 0, 0));
5202
5203 let r = _mm_cvtpd_epi32(_mm_setr_pd(f64::INFINITY, f64::NEG_INFINITY));
5204 assert_eq_m128i(r, _mm_setr_epi32(i32::MIN, i32::MIN, 0, 0));
5205
5206 let r = _mm_cvtpd_epi32(_mm_setr_pd(f64::NAN, f64::NAN));
5207 assert_eq_m128i(r, _mm_setr_epi32(i32::MIN, i32::MIN, 0, 0));
5208 }
5209
5210 #[simd_test(enable = "sse2")]
5211 fn test_mm_cvtsd_si32() {
5212 let r = _mm_cvtsd_si32(_mm_setr_pd(-2.0, 5.0));
5213 assert_eq!(r, -2);
5214
5215 let r = _mm_cvtsd_si32(_mm_setr_pd(f64::MAX, f64::MIN));
5216 assert_eq!(r, i32::MIN);
5217
5218 let r = _mm_cvtsd_si32(_mm_setr_pd(f64::NAN, f64::NAN));
5219 assert_eq!(r, i32::MIN);
5220 }
5221
5222 #[simd_test(enable = "sse2")]
5223 fn test_mm_cvtsd_ss() {
5224 let a = _mm_setr_ps(-1.1, -2.2, 3.3, 4.4);
5225 let b = _mm_setr_pd(2.0, -5.0);
5226
5227 let r = _mm_cvtsd_ss(a, b);
5228
5229 assert_eq_m128(r, _mm_setr_ps(2.0, -2.2, 3.3, 4.4));
5230
5231 let a = _mm_setr_ps(-1.1, f32::NEG_INFINITY, f32::MAX, f32::NEG_INFINITY);
5232 let b = _mm_setr_pd(f64::INFINITY, -5.0);
5233
5234 let r = _mm_cvtsd_ss(a, b);
5235
5236 assert_eq_m128(
5237 r,
5238 _mm_setr_ps(
5239 f32::INFINITY,
5240 f32::NEG_INFINITY,
5241 f32::MAX,
5242 f32::NEG_INFINITY,
5243 ),
5244 );
5245 }
5246
5247 #[simd_test(enable = "sse2")]
5248 const fn test_mm_cvtsd_f64() {
5249 let r = _mm_cvtsd_f64(_mm_setr_pd(-1.1, 2.2));
5250 assert_eq!(r, -1.1);
5251 }
5252
5253 #[simd_test(enable = "sse2")]
5254 const fn test_mm_cvtss_sd() {
5255 let a = _mm_setr_pd(-1.1, 2.2);
5256 let b = _mm_setr_ps(1.0, 2.0, 3.0, 4.0);
5257
5258 let r = _mm_cvtss_sd(a, b);
5259 assert_eq_m128d(r, _mm_setr_pd(1.0, 2.2));
5260
5261 let a = _mm_setr_pd(-1.1, f64::INFINITY);
5262 let b = _mm_setr_ps(f32::NEG_INFINITY, 2.0, 3.0, 4.0);
5263
5264 let r = _mm_cvtss_sd(a, b);
5265 assert_eq_m128d(r, _mm_setr_pd(f64::NEG_INFINITY, f64::INFINITY));
5266 }
5267
5268 #[simd_test(enable = "sse2")]
5269 fn test_mm_cvttpd_epi32() {
5270 let a = _mm_setr_pd(-1.1, 2.2);
5271 let r = _mm_cvttpd_epi32(a);
5272 assert_eq_m128i(r, _mm_setr_epi32(-1, 2, 0, 0));
5273
5274 let a = _mm_setr_pd(f64::NEG_INFINITY, f64::NAN);
5275 let r = _mm_cvttpd_epi32(a);
5276 assert_eq_m128i(r, _mm_setr_epi32(i32::MIN, i32::MIN, 0, 0));
5277 }
5278
5279 #[simd_test(enable = "sse2")]
5280 fn test_mm_cvttsd_si32() {
5281 let a = _mm_setr_pd(-1.1, 2.2);
5282 let r = _mm_cvttsd_si32(a);
5283 assert_eq!(r, -1);
5284
5285 let a = _mm_setr_pd(f64::NEG_INFINITY, f64::NAN);
5286 let r = _mm_cvttsd_si32(a);
5287 assert_eq!(r, i32::MIN);
5288 }
5289
5290 #[simd_test(enable = "sse2")]
5291 fn test_mm_cvttps_epi32() {
5292 let a = _mm_setr_ps(-1.1, 2.2, -3.3, 6.6);
5293 let r = _mm_cvttps_epi32(a);
5294 assert_eq_m128i(r, _mm_setr_epi32(-1, 2, -3, 6));
5295
5296 let a = _mm_setr_ps(f32::NEG_INFINITY, f32::INFINITY, f32::MIN, f32::MAX);
5297 let r = _mm_cvttps_epi32(a);
5298 assert_eq_m128i(r, _mm_setr_epi32(i32::MIN, i32::MIN, i32::MIN, i32::MIN));
5299 }
5300
5301 #[simd_test(enable = "sse2")]
5302 const fn test_mm_set_sd() {
5303 let r = _mm_set_sd(-1.0_f64);
5304 assert_eq_m128d(r, _mm_setr_pd(-1.0_f64, 0_f64));
5305 }
5306
5307 #[simd_test(enable = "sse2")]
5308 const fn test_mm_set1_pd() {
5309 let r = _mm_set1_pd(-1.0_f64);
5310 assert_eq_m128d(r, _mm_setr_pd(-1.0_f64, -1.0_f64));
5311 }
5312
5313 #[simd_test(enable = "sse2")]
5314 const fn test_mm_set_pd1() {
5315 let r = _mm_set_pd1(-2.0_f64);
5316 assert_eq_m128d(r, _mm_setr_pd(-2.0_f64, -2.0_f64));
5317 }
5318
5319 #[simd_test(enable = "sse2")]
5320 const fn test_mm_set_pd() {
5321 let r = _mm_set_pd(1.0_f64, 5.0_f64);
5322 assert_eq_m128d(r, _mm_setr_pd(5.0_f64, 1.0_f64));
5323 }
5324
5325 #[simd_test(enable = "sse2")]
5326 const fn test_mm_setr_pd() {
5327 let r = _mm_setr_pd(1.0_f64, -5.0_f64);
5328 assert_eq_m128d(r, _mm_setr_pd(1.0_f64, -5.0_f64));
5329 }
5330
5331 #[simd_test(enable = "sse2")]
5332 const fn test_mm_setzero_pd() {
5333 let r = _mm_setzero_pd();
5334 assert_eq_m128d(r, _mm_setr_pd(0_f64, 0_f64));
5335 }
5336
5337 #[simd_test(enable = "sse2")]
5338 const fn test_mm_load1_pd() {
5339 let d = -5.0;
5340 let r = unsafe { _mm_load1_pd(&d) };
5341 assert_eq_m128d(r, _mm_setr_pd(d, d));
5342 }
5343
5344 #[simd_test(enable = "sse2")]
5345 const fn test_mm_load_pd1() {
5346 let d = -5.0;
5347 let r = unsafe { _mm_load_pd1(&d) };
5348 assert_eq_m128d(r, _mm_setr_pd(d, d));
5349 }
5350
5351 #[simd_test(enable = "sse2")]
5352 const fn test_mm_unpackhi_pd() {
5353 let a = _mm_setr_pd(1.0, 2.0);
5354 let b = _mm_setr_pd(3.0, 4.0);
5355 let r = _mm_unpackhi_pd(a, b);
5356 assert_eq_m128d(r, _mm_setr_pd(2.0, 4.0));
5357 }
5358
5359 #[simd_test(enable = "sse2")]
5360 const fn test_mm_unpacklo_pd() {
5361 let a = _mm_setr_pd(1.0, 2.0);
5362 let b = _mm_setr_pd(3.0, 4.0);
5363 let r = _mm_unpacklo_pd(a, b);
5364 assert_eq_m128d(r, _mm_setr_pd(1.0, 3.0));
5365 }
5366
5367 #[simd_test(enable = "sse2")]
5368 const fn test_mm_shuffle_pd() {
5369 let a = _mm_setr_pd(1., 2.);
5370 let b = _mm_setr_pd(3., 4.);
5371 let expected = _mm_setr_pd(1., 3.);
5372 let r = _mm_shuffle_pd::<0b00_00_00_00>(a, b);
5373 assert_eq_m128d(r, expected);
5374 }
5375
5376 #[simd_test(enable = "sse2")]
5377 const fn test_mm_move_sd() {
5378 let a = _mm_setr_pd(1., 2.);
5379 let b = _mm_setr_pd(3., 4.);
5380 let expected = _mm_setr_pd(3., 2.);
5381 let r = _mm_move_sd(a, b);
5382 assert_eq_m128d(r, expected);
5383 }
5384
5385 #[simd_test(enable = "sse2")]
5386 const fn test_mm_castpd_ps() {
5387 let a = _mm_set1_pd(0.);
5388 let expected = _mm_set1_ps(0.);
5389 let r = _mm_castpd_ps(a);
5390 assert_eq_m128(r, expected);
5391 }
5392
5393 #[simd_test(enable = "sse2")]
5394 const fn test_mm_castpd_si128() {
5395 let a = _mm_set1_pd(0.);
5396 let expected = _mm_set1_epi64x(0);
5397 let r = _mm_castpd_si128(a);
5398 assert_eq_m128i(r, expected);
5399 }
5400
5401 #[simd_test(enable = "sse2")]
5402 const fn test_mm_castps_pd() {
5403 let a = _mm_set1_ps(0.);
5404 let expected = _mm_set1_pd(0.);
5405 let r = _mm_castps_pd(a);
5406 assert_eq_m128d(r, expected);
5407 }
5408
5409 #[simd_test(enable = "sse2")]
5410 const fn test_mm_castps_si128() {
5411 let a = _mm_set1_ps(0.);
5412 let expected = _mm_set1_epi32(0);
5413 let r = _mm_castps_si128(a);
5414 assert_eq_m128i(r, expected);
5415 }
5416
5417 #[simd_test(enable = "sse2")]
5418 const fn test_mm_castsi128_pd() {
5419 let a = _mm_set1_epi64x(0);
5420 let expected = _mm_set1_pd(0.);
5421 let r = _mm_castsi128_pd(a);
5422 assert_eq_m128d(r, expected);
5423 }
5424
5425 #[simd_test(enable = "sse2")]
5426 const fn test_mm_castsi128_ps() {
5427 let a = _mm_set1_epi32(0);
5428 let expected = _mm_set1_ps(0.);
5429 let r = _mm_castsi128_ps(a);
5430 assert_eq_m128(r, expected);
5431 }
5432}