1
1
use crate :: simd:: {
2
2
cmp:: SimdPartialOrd ,
3
3
ptr:: { SimdConstPtr , SimdMutPtr } ,
4
+ num:: SimdUint ,
4
5
LaneCount , Mask , MaskElement , SupportedLaneCount , Swizzle ,
5
6
} ;
6
7
@@ -1190,14 +1191,13 @@ where
1190
1191
}
1191
1192
1192
1193
#[ inline]
1193
- fn lane_indices < T , const N : usize > ( ) -> Simd < T , N >
1194
+ fn lane_indices < const N : usize > ( ) -> Simd < usize , N >
1194
1195
where
1195
- T : MaskElement + Default + core:: convert:: From < i8 > + core:: ops:: Add < T , Output = T > ,
1196
1196
LaneCount < N > : SupportedLaneCount ,
1197
1197
{
1198
- let mut index = [ T :: default ( ) ; N ] ;
1199
- for i in 1 ..N {
1200
- index[ i] = index [ i - 1 ] + T :: from ( 1 ) ;
1198
+ let mut index = [ 0 ; N ] ;
1199
+ for i in 0 ..N {
1200
+ index[ i] = i ;
1201
1201
}
1202
1202
Simd :: from_array ( index)
1203
1203
}
@@ -1208,7 +1208,18 @@ where
1208
1208
LaneCount < N > : SupportedLaneCount ,
1209
1209
M : MaskElement ,
1210
1210
{
1211
- let index = lane_indices :: < i8 , N > ( ) ;
1212
- let lt = index. simd_lt ( Simd :: splat ( i8:: try_from ( len) . unwrap_or ( i8:: MAX ) ) ) ;
1213
- lt. cast ( )
1211
+ let index = lane_indices :: < N > ( ) ;
1212
+ let max_value: u64 = M :: max_unsigned ( ) ;
1213
+ macro_rules! case {
1214
+ ( $ty: ty) => {
1215
+ if N < <$ty>:: MAX as usize && max_value as $ty as u64 == max_value {
1216
+ return index. cast( ) . simd_lt( Simd :: splat( len. min( N ) as $ty) ) . cast( ) ;
1217
+ }
1218
+ } ;
1219
+ }
1220
+ case ! ( u8 ) ;
1221
+ case ! ( u16 ) ;
1222
+ case ! ( u32 ) ;
1223
+ case ! ( u64 ) ;
1224
+ index. simd_lt ( Simd :: splat ( len) ) . cast ( )
1214
1225
}
0 commit comments