1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use crate::core::ops::BitXor;
use crate::vecs::*;
pub trait Eq : Packed {
type Out : Pattern + BitXor<Self::Out, Output = Self::Out>;
fn eq_mask(&self, other: Self) -> Self::Out;
#[inline(always)]
fn ne_mask(&self, other: Self) -> Self::Out { self.eq_mask(other) ^ Self::Out::ones() }
}
macro_rules! rust_fallback_eq {
(impl $trait:tt for $type:tt where $feat:tt {
$($newfn:ident, $rustfn:ident => $mask:tt, $maskel:tt, $mmfn:tt ( $($mmfnargs:expr),* ), [$($n:expr),+]);*;}) => (
impl $trait for $type {
$(
type Out = $mask;
#[inline(always)]
#[cfg(target_feature = $feat)]
fn $newfn(&self, other: Self) -> $mask {
use crate::core::mem::transmute;
unsafe { transmute($mmfn(transmute(*self), transmute(other), $($mmfnargs),*)) }
}
#[inline(always)]
#[cfg(not(target_feature = $feat))]
fn $newfn(&self, other: Self) -> Self::Out {
fallback!();
use crate::core::mem::transmute;
unsafe {
Self::Out::new($(transmute(if self.extract($n).$rustfn(&other.extract($n)) {
$maskel::max_value()
} else {
$maskel::min_value()
})),*)
}
}
)*
}
);
}
macro_rules! test_packed_eq {
($vec:tt, $el:tt, $mask:tt, $maskel:tt, $name:tt) => {
#[test]
fn $name() {
assert_eq!($vec::halfs(1 as $el, 0 as $el).eq_mask($vec::splat(0 as $el)),
$mask::halfs(0, $maskel::max_value()));
assert_eq!($vec::interleave(1 as $el, 0 as $el).eq_mask($vec::splat(1 as $el)),
$mask::interleave($maskel::max_value(), 0));
assert_eq!($vec::halfs(1 as $el, 0 as $el).ne_mask($vec::splat(0 as $el)),
$mask::halfs($maskel::max_value(), 0));
assert_eq!($vec::interleave(1 as $el, 0 as $el).ne_mask($vec::splat(1 as $el)),
$mask::interleave(0, $maskel::max_value()));
}
}
}