]> git.proxmox.com Git - rustc.git/blob - vendor/packed_simd_2/src/codegen/reductions/mask/x86/sse2.rs
Update upstream source from tag 'upstream/1.53.0+dfsg1'
[rustc.git] / vendor / packed_simd_2 / src / codegen / reductions / mask / x86 / sse2.rs
1 //! Mask reductions implementation for `x86` and `x86_64` targets with `SSE2`.
2 #![allow(unused)]
3
4 /// `x86`/`x86_64` 128-bit m64x2 `SSE2` implementation
5 macro_rules! x86_m64x2_sse2_impl {
6 ($id:ident) => {
7 impl All for $id {
8 #[inline]
9 #[target_feature(enable = "sse")]
10 unsafe fn all(self) -> bool {
11 #[cfg(target_arch = "x86")]
12 use crate::arch::x86::_mm_movemask_pd;
13 #[cfg(target_arch = "x86_64")]
14 use crate::arch::x86_64::_mm_movemask_pd;
15 // _mm_movemask_pd(a) creates a 2bit mask containing the
16 // most significant bit of each lane of `a`. If all
17 // bits are set, then all 2 lanes of the mask are
18 // true.
19 _mm_movemask_pd(crate::mem::transmute(self))
20 == 0b_11_i32
21 }
22 }
23 impl Any for $id {
24 #[inline]
25 #[target_feature(enable = "sse")]
26 unsafe fn any(self) -> bool {
27 #[cfg(target_arch = "x86")]
28 use crate::arch::x86::_mm_movemask_pd;
29 #[cfg(target_arch = "x86_64")]
30 use crate::arch::x86_64::_mm_movemask_pd;
31
32 _mm_movemask_pd(crate::mem::transmute(self)) != 0
33 }
34 }
35 };
36 }
37
38 /// `x86`/`x86_64` 128-bit m8x16 `SSE2` implementation
39 macro_rules! x86_m8x16_sse2_impl {
40 ($id:ident) => {
41 impl All for $id {
42 #[inline]
43 #[target_feature(enable = "sse2")]
44 unsafe fn all(self) -> bool {
45 #[cfg(target_arch = "x86")]
46 use crate::arch::x86::_mm_movemask_epi8;
47 #[cfg(target_arch = "x86_64")]
48 use crate::arch::x86_64::_mm_movemask_epi8;
49 // _mm_movemask_epi8(a) creates a 16bit mask containing the
50 // most significant bit of each byte of `a`. If all
51 // bits are set, then all 16 lanes of the mask are
52 // true.
53 _mm_movemask_epi8(crate::mem::transmute(self))
54 == i32::from(u16::max_value())
55 }
56 }
57 impl Any for $id {
58 #[inline]
59 #[target_feature(enable = "sse2")]
60 unsafe fn any(self) -> bool {
61 #[cfg(target_arch = "x86")]
62 use crate::arch::x86::_mm_movemask_epi8;
63 #[cfg(target_arch = "x86_64")]
64 use crate::arch::x86_64::_mm_movemask_epi8;
65
66 _mm_movemask_epi8(crate::mem::transmute(self)) != 0
67 }
68 }
69 };
70 }