@@ -362,6 +362,8 @@ impl_from_bits_!(
362
362
extern "C" {
363
363
#[ link_name = "llvm.ppc.altivec.vperm" ]
364
364
fn vperm ( a : vector_signed_int , b : vector_signed_int , c : vector_unsigned_char ) -> vector_signed_int ;
365
+ #[ link_name = "llvm.ppc.altivec.vmhaddshs" ]
366
+ fn vmhaddshs ( a : vector_signed_short , b : vector_signed_short , c : vector_signed_short ) -> vector_signed_short ;
365
367
}
366
368
367
369
mod sealed {
@@ -723,6 +725,15 @@ mod endian {
723
725
b. vec_vperm ( a, c)
724
726
}
725
727
}
728
+
729
+ /// Vector Multiply Add Saturated
730
+ #[ inline]
731
+ #[ target_feature( enable = "altivec" ) ]
732
+ #[ cfg_attr( test, assert_instr( vmhaddshs) ) ]
733
+ pub unsafe fn vec_madds ( a : vector_signed_short , b : vector_signed_short , c : vector_signed_short ) -> vector_signed_short {
734
+ vmhaddshs ( a, b, c)
735
+ }
736
+
726
737
#[ cfg( target_endian = "big" ) ]
727
738
mod endian {
728
739
use super :: * ;
@@ -837,6 +848,17 @@ mod tests {
837
848
0x04 , 0x05 , 0x06 , 0x07 , 0x14 , 0x15 , 0x16 , 0x17 ] ,
838
849
[ 0.0 , 1.0 , 1.0 , 1.1 ] }
839
850
851
+ #[ simd_test( enable = "altivec" ) ]
852
+ unsafe fn test_vec_madds ( ) {
853
+ let a: vector_signed_short = i16x8:: new ( 0 * 256 , 1 * 256 , 2 * 256 , 3 * 256 , 4 * 256 , 5 * 256 , 6 * 256 , 7 * 256 ) . into_bits ( ) ;
854
+ let b: vector_signed_short = i16x8:: new ( 256 , 256 , 256 , 256 , 256 , 256 , 256 , 256 ) . into_bits ( ) ;
855
+ let c: vector_signed_short = i16x8:: new ( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ) . into_bits ( ) ;
856
+
857
+ let d = i16x8:: new ( 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 ) ;
858
+
859
+ assert_eq ! ( d, vec_madds( a, b, c) . into_bits( ) ) ;
860
+ }
861
+
840
862
#[ simd_test( enable = "altivec" ) ]
841
863
unsafe fn vec_add_i32x4_i32x4 ( ) {
842
864
let x = i32x4:: new ( 1 , 2 , 3 , 4 ) ;
0 commit comments