@@ -9,7 +9,7 @@ pub use uint::*;
9
9
// Vectors of pointers are not for public use at the current time.
10
10
pub ( crate ) mod ptr;
11
11
12
- use crate :: { LaneCount , MaskElement , SupportedLaneCount } ;
12
+ use crate :: { LaneCount , Mask , MaskElement , SupportedLaneCount } ;
13
13
14
14
/// A SIMD vector of `LANES` elements of type `Element`.
15
15
#[ repr( simd) ]
@@ -54,16 +54,16 @@ where
54
54
/// # #![feature(portable_simd)]
55
55
/// # use core_simd::*;
56
56
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
57
- /// let idxs = SimdUsize::<4> ::from_array([9, 3, 0, 5]);
58
- /// let alt = SimdI32 ::from_array([-5, -4, -3, -2]);
57
+ /// let idxs = Simd ::from_array([9, 3, 0, 5]);
58
+ /// let alt = Simd ::from_array([-5, -4, -3, -2]);
59
59
///
60
- /// let result = SimdI32::<4> ::gather_or(&vec, idxs, alt); // Note the lane that is out-of-bounds.
61
- /// assert_eq!(result, SimdI32 ::from_array([-5, 13, 10, 15]));
60
+ /// let result = Simd ::gather_or(&vec, idxs, alt); // Note the lane that is out-of-bounds.
61
+ /// assert_eq!(result, Simd ::from_array([-5, 13, 10, 15]));
62
62
/// ```
63
63
#[ must_use]
64
64
#[ inline]
65
- pub fn gather_or ( slice : & [ Element ] , idxs : crate :: SimdUsize < LANES > , or : Self ) -> Self {
66
- Self :: gather_select ( slice, crate :: MaskSize :: splat ( true ) , idxs, or)
65
+ pub fn gather_or ( slice : & [ Element ] , idxs : Simd < usize , LANES > , or : Self ) -> Self {
66
+ Self :: gather_select ( slice, Mask :: splat ( true ) , idxs, or)
67
67
}
68
68
69
69
/// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices.
@@ -72,14 +72,14 @@ where
72
72
/// # #![feature(portable_simd)]
73
73
/// # use core_simd::*;
74
74
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
75
- /// let idxs = SimdUsize::<4> ::from_array([9, 3, 0, 5]);
75
+ /// let idxs = Simd ::from_array([9, 3, 0, 5]);
76
76
///
77
- /// let result = SimdI32::<4> ::gather_or_default(&vec, idxs); // Note the lane that is out-of-bounds.
78
- /// assert_eq!(result, SimdI32 ::from_array([0, 13, 10, 15]));
77
+ /// let result = Simd ::gather_or_default(&vec, idxs); // Note the lane that is out-of-bounds.
78
+ /// assert_eq!(result, Simd ::from_array([0, 13, 10, 15]));
79
79
/// ```
80
80
#[ must_use]
81
81
#[ inline]
82
- pub fn gather_or_default ( slice : & [ Element ] , idxs : crate :: SimdUsize < LANES > ) -> Self
82
+ pub fn gather_or_default ( slice : & [ Element ] , idxs : Simd < usize , LANES > ) -> Self
83
83
where
84
84
Element : Default ,
85
85
{
@@ -92,22 +92,22 @@ where
92
92
/// # #![feature(portable_simd)]
93
93
/// # use core_simd::*;
94
94
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
95
- /// let idxs = SimdUsize::<4> ::from_array([9, 3, 0, 5]);
96
- /// let alt = SimdI32 ::from_array([-5, -4, -3, -2]);
97
- /// let mask = MaskSize ::from_array([true, true, true, false]); // Note the mask of the last lane.
95
+ /// let idxs = Simd ::from_array([9, 3, 0, 5]);
96
+ /// let alt = Simd ::from_array([-5, -4, -3, -2]);
97
+ /// let mask = Mask ::from_array([true, true, true, false]); // Note the mask of the last lane.
98
98
///
99
- /// let result = SimdI32::<4> ::gather_select(&vec, mask, idxs, alt); // Note the lane that is out-of-bounds.
100
- /// assert_eq!(result, SimdI32 ::from_array([-5, 13, 10, -2]));
99
+ /// let result = Simd ::gather_select(&vec, mask, idxs, alt); // Note the lane that is out-of-bounds.
100
+ /// assert_eq!(result, Simd ::from_array([-5, 13, 10, -2]));
101
101
/// ```
102
102
#[ must_use]
103
103
#[ inline]
104
104
pub fn gather_select (
105
105
slice : & [ Element ] ,
106
- mask : crate :: MaskSize < LANES > ,
107
- idxs : crate :: SimdUsize < LANES > ,
106
+ mask : Mask < isize , LANES > ,
107
+ idxs : Simd < usize , LANES > ,
108
108
or : Self ,
109
109
) -> Self {
110
- let mask = ( mask & idxs. lanes_lt ( crate :: SimdUsize :: splat ( slice. len ( ) ) ) ) . to_int ( ) ;
110
+ let mask = ( mask & idxs. lanes_lt ( Simd :: splat ( slice. len ( ) ) ) ) . to_int ( ) ;
111
111
let base_ptr = crate :: vector:: ptr:: SimdConstPtr :: splat ( slice. as_ptr ( ) ) ;
112
112
// Ferris forgive me, I have done pointer arithmetic here.
113
113
let ptrs = base_ptr. wrapping_add ( idxs) ;
@@ -122,15 +122,15 @@ where
122
122
/// # #![feature(portable_simd)]
123
123
/// # use core_simd::*;
124
124
/// let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
125
- /// let idxs = SimdUsize::<4> ::from_array([9, 3, 0, 0]);
126
- /// let vals = SimdI32 ::from_array([-27, 82, -41, 124]);
125
+ /// let idxs = Simd ::from_array([9, 3, 0, 0]);
126
+ /// let vals = Simd ::from_array([-27, 82, -41, 124]);
127
127
///
128
128
/// vals.scatter(&mut vec, idxs); // index 0 receives two writes.
129
129
/// assert_eq!(vec, vec![124, 11, 12, 82, 14, 15, 16, 17, 18]);
130
130
/// ```
131
131
#[ inline]
132
- pub fn scatter ( self , slice : & mut [ Element ] , idxs : crate :: SimdUsize < LANES > ) {
133
- self . scatter_select ( slice, crate :: MaskSize :: splat ( true ) , idxs)
132
+ pub fn scatter ( self , slice : & mut [ Element ] , idxs : Simd < usize , LANES > ) {
133
+ self . scatter_select ( slice, Mask :: splat ( true ) , idxs)
134
134
}
135
135
136
136
/// SIMD scatter: write a SIMD vector's values into a slice, using potentially discontiguous indices.
@@ -140,9 +140,9 @@ where
140
140
/// # #![feature(portable_simd)]
141
141
/// # use core_simd::*;
142
142
/// let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
143
- /// let idxs = SimdUsize::<4> ::from_array([9, 3, 0, 0]);
144
- /// let vals = SimdI32 ::from_array([-27, 82, -41, 124]);
145
- /// let mask = MaskSize ::from_array([true, true, true, false]); // Note the mask of the last lane.
143
+ /// let idxs = Simd ::from_array([9, 3, 0, 0]);
144
+ /// let vals = Simd ::from_array([-27, 82, -41, 124]);
145
+ /// let mask = Mask ::from_array([true, true, true, false]); // Note the mask of the last lane.
146
146
///
147
147
/// vals.scatter_select(&mut vec, mask, idxs); // index 0's second write is masked, thus omitted.
148
148
/// assert_eq!(vec, vec![-41, 11, 12, 82, 14, 15, 16, 17, 18]);
@@ -151,11 +151,11 @@ where
151
151
pub fn scatter_select (
152
152
self ,
153
153
slice : & mut [ Element ] ,
154
- mask : crate :: MaskSize < LANES > ,
155
- idxs : crate :: SimdUsize < LANES > ,
154
+ mask : Mask < isize , LANES > ,
155
+ idxs : Simd < usize , LANES > ,
156
156
) {
157
157
// We must construct our scatter mask before we derive a pointer!
158
- let mask = ( mask & idxs. lanes_lt ( crate :: SimdUsize :: splat ( slice. len ( ) ) ) ) . to_int ( ) ;
158
+ let mask = ( mask & idxs. lanes_lt ( Simd :: splat ( slice. len ( ) ) ) ) . to_int ( ) ;
159
159
// SAFETY: This block works with *mut T derived from &mut 'a [T],
160
160
// which means it is delicate in Rust's borrowing model, circa 2021:
161
161
// &mut 'a [T] asserts uniqueness, so deriving &'a [T] invalidates live *mut Ts!
0 commit comments