@@ -7,6 +7,7 @@ use core::ops::{Shr, Shl};
7
7
8
8
mod assign;
9
9
mod deref;
10
+ mod splat;
10
11
mod unary;
11
12
12
13
impl < I , T , const LANES : usize > core:: ops:: Index < I > for Simd < T , LANES >
@@ -119,20 +120,6 @@ macro_rules! impl_op {
119
120
}
120
121
}
121
122
122
- impl_ref_ops! {
123
- impl <const LANES : usize > core:: ops:: $trait<$scalar> for Simd <$scalar, LANES >
124
- where
125
- LaneCount <LANES >: SupportedLaneCount ,
126
- {
127
- type Output = Self ;
128
-
129
- #[ inline]
130
- fn $trait_fn( self , rhs: $scalar) -> Self :: Output {
131
- core:: ops:: $trait:: $trait_fn( self , Self :: splat( rhs) )
132
- }
133
- }
134
- }
135
-
136
123
impl_ref_ops! {
137
124
impl <const LANES : usize > core:: ops:: $trait<Simd <$scalar, LANES >> for $scalar
138
125
where
@@ -202,29 +189,6 @@ macro_rules! impl_unsigned_int_ops {
202
189
}
203
190
}
204
191
205
- impl_ref_ops! {
206
- impl <const LANES : usize > core:: ops:: Div <$scalar> for Simd <$scalar, LANES >
207
- where
208
- LaneCount <LANES >: SupportedLaneCount ,
209
- {
210
- type Output = Self ;
211
-
212
- #[ inline]
213
- fn div( self , rhs: $scalar) -> Self :: Output {
214
- if rhs == 0 {
215
- panic!( "attempt to divide by zero" ) ;
216
- }
217
- if <$scalar>:: MIN != 0 &&
218
- self . as_array( ) . iter( ) . any( |x| * x == <$scalar>:: MIN ) &&
219
- rhs == -1 as _ {
220
- panic!( "attempt to divide with overflow" ) ;
221
- }
222
- let rhs = Self :: splat( rhs) ;
223
- unsafe { intrinsics:: simd_div( self , rhs) }
224
- }
225
- }
226
- }
227
-
228
192
impl_ref_ops! {
229
193
impl <const LANES : usize > core:: ops:: Div <Simd <$scalar, LANES >> for $scalar
230
194
where
@@ -268,29 +232,6 @@ macro_rules! impl_unsigned_int_ops {
268
232
}
269
233
}
270
234
271
- impl_ref_ops! {
272
- impl <const LANES : usize > core:: ops:: Rem <$scalar> for Simd <$scalar, LANES >
273
- where
274
- LaneCount <LANES >: SupportedLaneCount ,
275
- {
276
- type Output = Self ;
277
-
278
- #[ inline]
279
- fn rem( self , rhs: $scalar) -> Self :: Output {
280
- if rhs == 0 {
281
- panic!( "attempt to calculate the remainder with a divisor of zero" ) ;
282
- }
283
- if <$scalar>:: MIN != 0 &&
284
- self . as_array( ) . iter( ) . any( |x| * x == <$scalar>:: MIN ) &&
285
- rhs == -1 as _ {
286
- panic!( "attempt to calculate the remainder with overflow" ) ;
287
- }
288
- let rhs = Self :: splat( rhs) ;
289
- unsafe { intrinsics:: simd_rem( self , rhs) }
290
- }
291
- }
292
- }
293
-
294
235
impl_ref_ops! {
295
236
impl <const LANES : usize > core:: ops:: Rem <Simd <$scalar, LANES >> for $scalar
296
237
where
@@ -328,24 +269,6 @@ macro_rules! impl_unsigned_int_ops {
328
269
}
329
270
}
330
271
331
- impl_ref_ops! {
332
- impl <const LANES : usize > core:: ops:: Shl <$scalar> for Simd <$scalar, LANES >
333
- where
334
- LaneCount <LANES >: SupportedLaneCount ,
335
- {
336
- type Output = Self ;
337
-
338
- #[ inline]
339
- fn shl( self , rhs: $scalar) -> Self :: Output {
340
- if invalid_shift_rhs( rhs) {
341
- panic!( "attempt to shift left with overflow" ) ;
342
- }
343
- let rhs = Self :: splat( rhs) ;
344
- unsafe { intrinsics:: simd_shl( self , rhs) }
345
- }
346
- }
347
- }
348
-
349
272
impl_ref_ops! {
350
273
impl <const LANES : usize > core:: ops:: Shr <Self > for Simd <$scalar, LANES >
351
274
where
@@ -367,24 +290,6 @@ macro_rules! impl_unsigned_int_ops {
367
290
}
368
291
}
369
292
}
370
-
371
- impl_ref_ops! {
372
- impl <const LANES : usize > core:: ops:: Shr <$scalar> for Simd <$scalar, LANES >
373
- where
374
- LaneCount <LANES >: SupportedLaneCount ,
375
- {
376
- type Output = Self ;
377
-
378
- #[ inline]
379
- fn shr( self , rhs: $scalar) -> Self :: Output {
380
- if invalid_shift_rhs( rhs) {
381
- panic!( "attempt to shift with overflow" ) ;
382
- }
383
- let rhs = Self :: splat( rhs) ;
384
- unsafe { intrinsics:: simd_shr( self , rhs) }
385
- }
386
- }
387
- }
388
293
) *
389
294
} ;
390
295
}
0 commit comments