@@ -357,6 +357,10 @@ extern "C" {
357
357
fn vmhaddshs (
358
358
a : vector_signed_short , b : vector_signed_short , c : vector_signed_short ,
359
359
) -> vector_signed_short ;
360
+ #[ link_name = "llvm.ppc.altivec.vmhraddshs" ]
361
+ fn vmhraddshs (
362
+ a : vector_signed_short , b : vector_signed_short , c : vector_signed_short ,
363
+ ) -> vector_signed_short ;
360
364
}
361
365
362
366
mod sealed {
@@ -732,6 +736,16 @@ pub unsafe fn vec_madds(
732
736
vmhaddshs ( a, b, c)
733
737
}
734
738
739
+ /// Vector Multiply Round and Add Saturated
740
+ #[ inline]
741
+ #[ target_feature( enable = "altivec" ) ]
742
+ #[ cfg_attr( test, assert_instr( vmhraddshs) ) ]
743
+ pub unsafe fn vec_mradds (
744
+ a : vector_signed_short , b : vector_signed_short , c : vector_signed_short ,
745
+ ) -> vector_signed_short {
746
+ vmhraddshs ( a, b, c)
747
+ }
748
+
735
749
#[ cfg( target_endian = "big" ) ]
736
750
mod endian {
737
751
use super :: * ;
@@ -868,6 +882,28 @@ mod tests {
868
882
assert_eq ! ( d, vec_madds( a, b, c) . into_bits( ) ) ;
869
883
}
870
884
885
+ #[ simd_test( enable = "altivec" ) ]
886
+ unsafe fn test_vec_mradds ( ) {
887
+ let a: vector_signed_short = i16x8:: new (
888
+ 0 * 256 ,
889
+ 1 * 256 ,
890
+ 2 * 256 ,
891
+ 3 * 256 ,
892
+ 4 * 256 ,
893
+ 5 * 256 ,
894
+ 6 * 256 ,
895
+ 7 * 256 ,
896
+ ) . into_bits ( ) ;
897
+ let b: vector_signed_short =
898
+ i16x8:: new ( 256 , 256 , 256 , 256 , 256 , 256 , 256 , 256 ) . into_bits ( ) ;
899
+ let c: vector_signed_short =
900
+ i16x8:: new ( 0 , 1 , 2 , 3 , 4 , 5 , 6 , i16:: max_value ( ) - 1 ) . into_bits ( ) ;
901
+
902
+ let d = i16x8:: new ( 0 , 3 , 6 , 9 , 12 , 15 , 18 , i16:: max_value ( ) ) ;
903
+
904
+ assert_eq ! ( d, vec_madds( a, b, c) . into_bits( ) ) ;
905
+ }
906
+
871
907
#[ simd_test( enable = "altivec" ) ]
872
908
unsafe fn vec_add_i32x4_i32x4 ( ) {
873
909
let x = i32x4:: new ( 1 , 2 , 3 , 4 ) ;
0 commit comments