File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
crates/core_simd/src/masks/full_masks Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,13 @@ macro_rules! define_mask {
22
22
impl <const $lanes: usize > $name<$lanes> {
23
23
/// Construct a mask by setting all lanes to the given value.
24
24
pub fn splat( value: bool ) -> Self {
25
- Self ( <$type>:: splat( value. into( ) ) )
25
+ Self ( <$type>:: splat(
26
+ if value {
27
+ -1
28
+ } else {
29
+ 0
30
+ }
31
+ ) )
26
32
}
27
33
28
34
/// Tests the value of the specified lane.
@@ -31,7 +37,7 @@ macro_rules! define_mask {
31
37
/// Panics if `lane` is greater than or equal to the number of lanes in the vector.
32
38
#[ inline]
33
39
pub fn test( & self , lane: usize ) -> bool {
34
- self . 0 [ lane] > 0
40
+ self . 0 [ lane] == - 1
35
41
}
36
42
37
43
/// Sets the value of the specified lane.
@@ -41,7 +47,7 @@ macro_rules! define_mask {
41
47
#[ inline]
42
48
pub fn set( & mut self , lane: usize , value: bool ) {
43
49
self . 0 [ lane] = if value {
44
- ! 0
50
+ - 1
45
51
} else {
46
52
0
47
53
}
@@ -57,7 +63,7 @@ macro_rules! define_mask {
57
63
impl <const $lanes: usize > core:: convert:: TryFrom <$type> for $name<$lanes> {
58
64
type Error = TryFromMaskError ;
59
65
fn try_from( value: $type) -> Result <Self , Self :: Error > {
60
- if value. as_slice( ) . iter( ) . all( |x| * x == 0 || ! * x == 0 ) {
66
+ if value. as_slice( ) . iter( ) . all( |x| * x == 0 || * x == - 1 ) {
61
67
Ok ( Self ( value) )
62
68
} else {
63
69
Err ( TryFromMaskError ( ( ) ) )
You can’t perform that action at this time.
0 commit comments