@@ -337,6 +337,44 @@ mod sealed {
337
337
}
338
338
}
339
339
340
+ #[ inline]
341
+ #[ target_feature( enable = "altivec" ) ]
342
+ #[ cfg_attr( all( test, not( target_feature = "vsx" ) ) , assert_instr( vandc) ) ]
343
+ #[ cfg_attr( all( test, target_feature = "vsx" ) , assert_instr( xxlandc) ) ]
344
+ unsafe fn andc ( a : u8x16 , b : u8x16 ) -> u8x16 {
345
+ simd_and ( simd_xor ( u8x16:: splat ( 0xff ) , b) , a)
346
+ }
347
+
348
+ pub trait VectorAndc < Other > {
349
+ type Result ;
350
+ unsafe fn vec_andc ( self , b : Other ) -> Self :: Result ;
351
+ }
352
+
353
+ macro_rules! impl_vec_andc {
354
+ ( ( $a: ty, $b: ty) -> $r: ty) => {
355
+ impl VectorAndc <$b> for $a {
356
+ type Result = $r;
357
+ #[ inline]
358
+ #[ target_feature( enable = "altivec" ) ]
359
+ unsafe fn vec_andc( self , b: $b) -> Self :: Result {
360
+ transmute( andc( transmute( self ) , transmute( b) ) )
361
+ }
362
+ }
363
+ } ;
364
+ ( ( $a: ty, ~$b: ty) -> $r: ty) => {
365
+ impl_vec_andc! { ( $a, $a) -> $r }
366
+ impl_vec_andc! { ( $a, $b) -> $r }
367
+ impl_vec_andc! { ( $b, $a) -> $r }
368
+ } ;
369
+ }
370
+
371
+ impl_vec_andc ! { ( vector_unsigned_char, ~vector_bool_char) -> vector_unsigned_char }
372
+ impl_vec_andc ! { ( vector_signed_char, ~vector_bool_char) -> vector_signed_char }
373
+ impl_vec_andc ! { ( vector_unsigned_short, ~vector_bool_short) -> vector_unsigned_short }
374
+ impl_vec_andc ! { ( vector_signed_short, ~vector_bool_short) -> vector_signed_short }
375
+ impl_vec_andc ! { ( vector_unsigned_int, ~vector_bool_int) -> vector_unsigned_int }
376
+ impl_vec_andc ! { ( vector_signed_int, ~vector_bool_int) -> vector_signed_int }
377
+
340
378
test_impl ! { vec_vand( a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ simd_and, vand / xxland ] }
341
379
342
380
pub trait VectorAnd < Other > {
@@ -1202,6 +1240,16 @@ mod sealed {
1202
1240
vector_mladd ! { vector_signed_short, vector_signed_short, vector_signed_short }
1203
1241
}
1204
1242
1243
+ /// Vector andc.
1244
+ #[ inline]
1245
+ #[ target_feature( enable = "altivec" ) ]
1246
+ pub unsafe fn vec_andc < T , U > ( a : T , b : U ) -> <T as sealed:: VectorAndc < U > >:: Result
1247
+ where
1248
+ T : sealed:: VectorAndc < U > ,
1249
+ {
1250
+ a. vec_andc ( b)
1251
+ }
1252
+
1205
1253
/// Vector and.
1206
1254
#[ inline]
1207
1255
#[ target_feature( enable = "altivec" ) ]
@@ -1516,6 +1564,11 @@ mod tests {
1516
1564
}
1517
1565
}
1518
1566
1567
+ test_vec_2 ! { test_vec_andc, vec_andc, i32x4,
1568
+ [ 0b11001100 , 0b11001100 , 0b11001100 , 0b11001100 ] ,
1569
+ [ 0b00110011 , 0b11110011 , 0b00001100 , 0b10000000 ] ,
1570
+ [ 0b11001100 , 0b00001100 , 0b11000000 , 0b01001100 ] }
1571
+
1519
1572
test_vec_2 ! { test_vec_and, vec_and, i32x4,
1520
1573
[ 0b11001100 , 0b11001100 , 0b11001100 , 0b11001100 ] ,
1521
1574
[ 0b00110011 , 0b11110011 , 0b00001100 , 0b00000000 ] ,
0 commit comments