]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
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. | |
f25598a0 | 19 | _mm_movemask_pd(crate::mem::transmute(self)) == 0b_11_i32 |
f20569fa XL |
20 | } |
21 | } | |
22 | impl Any for $id { | |
23 | #[inline] | |
24 | #[target_feature(enable = "sse")] | |
25 | unsafe fn any(self) -> bool { | |
26 | #[cfg(target_arch = "x86")] | |
27 | use crate::arch::x86::_mm_movemask_pd; | |
28 | #[cfg(target_arch = "x86_64")] | |
29 | use crate::arch::x86_64::_mm_movemask_pd; | |
30 | ||
31 | _mm_movemask_pd(crate::mem::transmute(self)) != 0 | |
32 | } | |
33 | } | |
34 | }; | |
35 | } | |
36 | ||
37 | /// `x86`/`x86_64` 128-bit m8x16 `SSE2` implementation | |
38 | macro_rules! x86_m8x16_sse2_impl { | |
39 | ($id:ident) => { | |
40 | impl All for $id { | |
41 | #[inline] | |
42 | #[target_feature(enable = "sse2")] | |
43 | unsafe fn all(self) -> bool { | |
44 | #[cfg(target_arch = "x86")] | |
45 | use crate::arch::x86::_mm_movemask_epi8; | |
46 | #[cfg(target_arch = "x86_64")] | |
47 | use crate::arch::x86_64::_mm_movemask_epi8; | |
48 | // _mm_movemask_epi8(a) creates a 16bit mask containing the | |
49 | // most significant bit of each byte of `a`. If all | |
50 | // bits are set, then all 16 lanes of the mask are | |
51 | // true. | |
f25598a0 | 52 | _mm_movemask_epi8(crate::mem::transmute(self)) == i32::from(u16::max_value()) |
f20569fa XL |
53 | } |
54 | } | |
55 | impl Any for $id { | |
56 | #[inline] | |
57 | #[target_feature(enable = "sse2")] | |
58 | unsafe fn any(self) -> bool { | |
59 | #[cfg(target_arch = "x86")] | |
60 | use crate::arch::x86::_mm_movemask_epi8; | |
61 | #[cfg(target_arch = "x86_64")] | |
62 | use crate::arch::x86_64::_mm_movemask_epi8; | |
63 | ||
64 | _mm_movemask_epi8(crate::mem::transmute(self)) != 0 | |
65 | } | |
66 | } | |
67 | }; | |
68 | } |