@@ -174,6 +174,16 @@ unsafe extern "unadjusted" {
174174 #[ link_name = "llvm.s390.vupllb" ] fn vupllb ( a : vector_unsigned_char ) -> vector_unsigned_short ;
175175 #[ link_name = "llvm.s390.vupllh" ] fn vupllh ( a : vector_unsigned_short ) -> vector_unsigned_int ;
176176 #[ link_name = "llvm.s390.vupllf" ] fn vupllf ( a : vector_unsigned_int ) -> vector_unsigned_long_long ;
177+
178+ #[ link_name = "llvm.s390.vavgb" ] fn vavgb ( a : vector_signed_char , b : vector_signed_char ) -> vector_signed_char ;
179+ #[ link_name = "llvm.s390.vavgh" ] fn vavgh ( a : vector_signed_short , b : vector_signed_short ) -> vector_signed_short ;
180+ #[ link_name = "llvm.s390.vavgf" ] fn vavgf ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_int ;
181+ #[ link_name = "llvm.s390.vavgg" ] fn vavgg ( a : vector_signed_long_long , b : vector_signed_long_long ) -> vector_signed_long_long ;
182+
183+ #[ link_name = "llvm.s390.vavglb" ] fn vavglb ( a : vector_unsigned_char , b : vector_unsigned_char ) -> vector_unsigned_char ;
184+ #[ link_name = "llvm.s390.vavglh" ] fn vavglh ( a : vector_unsigned_short , b : vector_unsigned_short ) -> vector_unsigned_short ;
185+ #[ link_name = "llvm.s390.vavglf" ] fn vavglf ( a : vector_unsigned_int , b : vector_unsigned_int ) -> vector_unsigned_int ;
186+ #[ link_name = "llvm.s390.vavglg" ] fn vavglg ( a : vector_unsigned_long_long , b : vector_unsigned_long_long ) -> vector_unsigned_long_long ;
177187}
178188
179189impl_from ! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -2356,6 +2366,24 @@ mod sealed {
23562366 impl_vec_trait ! { [ VectorUnpackl vec_unpackl] + vupllb ( vector_bool_char) -> vector_bool_short}
23572367 impl_vec_trait ! { [ VectorUnpackl vec_unpackl] + vupllh ( vector_bool_short) -> vector_bool_int}
23582368 impl_vec_trait ! { [ VectorUnpackl vec_unpackl] + vupllf ( vector_bool_int) -> vector_bool_long_long}
2369+
2370+ test_impl ! { vec_vavgb( a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ vavgb, vavgb ] }
2371+ test_impl ! { vec_vavgh( a: vector_signed_short, b: vector_signed_short) -> vector_signed_short [ vavgh, vavgh ] }
2372+ test_impl ! { vec_vavgf( a: vector_signed_int, b: vector_signed_int) -> vector_signed_int [ vavgf, vavgf ] }
2373+ test_impl ! { vec_vavgg( a: vector_signed_long_long, b: vector_signed_long_long) -> vector_signed_long_long [ vavgg, vavgg ] }
2374+
2375+ test_impl ! { vec_vavglb( a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char [ vavglb, vavglb ] }
2376+ test_impl ! { vec_vavglh( a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short [ vavglh, vavglh ] }
2377+ test_impl ! { vec_vavglf( a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [ vavglf, vavglf ] }
2378+ test_impl ! { vec_vavglg( a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> vector_unsigned_long_long [ vavglg, vavglg ] }
2379+
2380+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2381+ pub trait VectorAvg < Other > {
2382+ type Result ;
2383+ unsafe fn vec_avg ( self , b : Other ) -> Self :: Result ;
2384+ }
2385+
2386+ impl_vec_trait ! { [ VectorAvg vec_avg] 2 ( vec_vavglb, vec_vavgb, vec_vavglh, vec_vavgh, vec_vavglf, vec_vavgf, vec_vavglg, vec_vavgg) }
23592387}
23602388
23612389/// Load Count to Block Boundary
@@ -2732,6 +2760,14 @@ where
27322760 a. vec_rint ( )
27332761}
27342762
2763+ /// Vector Average
2764+ #[ inline]
2765+ #[ target_feature( enable = "vector" ) ]
2766+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2767+ pub unsafe fn vec_avg < T : sealed:: VectorAvg < U > , U > ( a : T , b : U ) -> T :: Result {
2768+ a. vec_avg ( b)
2769+ }
2770+
27352771/// Vector Shift Left
27362772#[ inline]
27372773#[ target_feature( enable = "vector" ) ]
@@ -4187,4 +4223,10 @@ mod tests {
41874223 [ 0 , 0 , 0 , 0 , 0x1234 , 0xFFFF , 0x0F0F , 0x8000 ] ,
41884224 [ 0x1234 , 0xFFFF , 0x0F0F , 0x8000 ]
41894225 }
4226+
4227+ test_vec_2 ! { test_vec_avg, vec_avg, u32x4,
4228+ [ 2 , 1 , u32 :: MAX , 0 ] ,
4229+ [ 4 , 2 , 2 , 0 ] ,
4230+ [ 3 , ( 1u32 + 2 ) . div_ceil( 2 ) , ( u32 :: MAX as u64 + 2u64 ) . div_ceil( 2 ) as u32 , 0 ]
4231+ }
41904232}
0 commit comments