@@ -74,9 +74,14 @@ unsafe extern "unadjusted" {
7474 #[ link_name = "llvm.umin.v4i32" ] fn vmnlf ( a : vector_unsigned_int , b : vector_unsigned_int ) -> vector_unsigned_int ;
7575 #[ link_name = "llvm.umin.v2i64" ] fn vmnlg ( a : vector_unsigned_long_long , b : vector_unsigned_long_long ) -> vector_unsigned_long_long ;
7676
77- #[ link_name = "llvm.s390.vfisb " ] fn vfisb ( a : vector_float , b : i32 , c : i32 ) -> vector_float ;
78- #[ link_name = "llvm.s390.vfidb " ] fn vfidb ( a : vector_double , b : i32 , c : i32 ) -> vector_double ;
77+ #[ link_name = "llvm.nearbyint.v4f32 " ] fn nearbyint_v4f32 ( a : vector_float ) -> vector_float ;
78+ #[ link_name = "llvm.nearbyint.v2f64 " ] fn nearbyint_v2f64 ( a : vector_double ) -> vector_double ;
7979
80+ #[ link_name = "llvm.rint.v4f32" ] fn rint_v4f32 ( a : vector_float ) -> vector_float ;
81+ #[ link_name = "llvm.rint.v2f64" ] fn rint_v2f64 ( a : vector_double ) -> vector_double ;
82+
83+ #[ link_name = "llvm.roundeven.v4f32" ] fn roundeven_v4f32 ( a : vector_float ) -> vector_float ;
84+ #[ link_name = "llvm.roundeven.v2f64" ] fn roundeven_v2f64 ( a : vector_double ) -> vector_double ;
8085}
8186
8287impl_from ! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -636,70 +641,67 @@ mod sealed {
636641
637642 impl_vec_trait ! { [ VectorOrc vec_orc] + 2 c ( orc) }
638643
644+ // FIXME(vector-enhancements-1) add instr tests for f32
645+ test_impl ! { vec_roundc_f32 ( a: vector_float) -> vector_float [ nearbyint_v4f32, _] }
646+ test_impl ! { vec_roundc_f64 ( a: vector_double) -> vector_double [ nearbyint_v2f64, vfidb] }
647+
648+ // FIXME(llvm) roundeven does not yet lower to vfidb (but should in the future)
649+ test_impl ! { vec_round_f32 ( a: vector_float) -> vector_float [ roundeven_v4f32, _] }
650+ test_impl ! { vec_round_f64 ( a: vector_double) -> vector_double [ roundeven_v2f64, _] }
651+
652+ test_impl ! { vec_rint_f32 ( a: vector_float) -> vector_float [ rint_v4f32, _] }
653+ test_impl ! { vec_rint_f64 ( a: vector_double) -> vector_double [ rint_v2f64, vfidb] }
654+
639655 #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
640- pub trait VectorRound : Sized {
641- unsafe fn vec_round_impl < const N : i32 , const MODE : i32 > ( self ) -> Self ;
656+ pub trait VectorRoundc {
657+ unsafe fn vec_roundc ( self ) -> Self ;
658+ }
642659
643- #[ inline]
644- #[ target_feature( enable = "vector" ) ]
645- unsafe fn vec_roundc ( self ) -> Self {
646- self . vec_round_impl :: < 4 , 0 > ( )
647- }
660+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
661+ pub trait VectorRound {
662+ unsafe fn vec_round ( self ) -> Self ;
663+ }
648664
649- #[ inline]
650- #[ target_feature( enable = "vector" ) ]
651- unsafe fn vec_round ( self ) -> Self {
652- // NOTE: simd_round resoles ties by rounding away from zero,
653- // while the vec_round function rounds towards zero
654- self . vec_round_impl :: < 4 , 4 > ( )
655- }
665+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
666+ pub trait VectorRint {
667+ unsafe fn vec_rint ( self ) -> Self ;
668+ }
656669
657- // NOTE: vec_roundz (vec_round_impl::<4, 5>) is the same as vec_trunc
658- #[ inline]
659- #[ target_feature( enable = "vector" ) ]
660- unsafe fn vec_trunc ( self ) -> Self {
661- simd_trunc ( self )
662- }
670+ impl_vec_trait ! { [ VectorRoundc vec_roundc] vec_roundc_f32 ( vector_float) }
671+ impl_vec_trait ! { [ VectorRoundc vec_roundc] vec_roundc_f64 ( vector_double) }
663672
664- // NOTE: vec_roundp (vec_round_impl::<4, 6>) is the same as vec_ceil
665- #[ inline]
666- #[ target_feature( enable = "vector" ) ]
667- unsafe fn vec_ceil ( self ) -> Self {
668- simd_ceil ( self )
669- }
673+ impl_vec_trait ! { [ VectorRound vec_round] vec_round_f32 ( vector_float) }
674+ impl_vec_trait ! { [ VectorRound vec_round] vec_round_f64 ( vector_double) }
670675
671- // NOTE: vec_roundm (vec_round_impl::<4, 7>) is the same as vec_floor
672- #[ inline]
673- #[ target_feature( enable = "vector" ) ]
674- unsafe fn vec_floor ( self ) -> Self {
675- simd_floor ( self )
676- }
676+ impl_vec_trait ! { [ VectorRint vec_rint] vec_rint_f32 ( vector_float) }
677+ impl_vec_trait ! { [ VectorRint vec_rint] vec_rint_f64 ( vector_double) }
677678
678- #[ inline]
679- #[ target_feature( enable = "vector" ) ]
680- unsafe fn vec_rint ( self ) -> Self {
681- self . vec_round_impl :: < 0 , 0 > ( )
682- }
679+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
680+ pub trait VectorTrunc {
681+ // same as vec_roundz
682+ unsafe fn vec_trunc ( self ) -> Self ;
683683 }
684684
685- // FIXME(vector-enhancements-1) apply the right target feature to all methods
686685 #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
687- impl VectorRound for vector_float {
688- #[ inline]
689- #[ target_feature( enable = "vector" ) ]
690- unsafe fn vec_round_impl < const N : i32 , const MODE : i32 > ( self ) -> Self {
691- vfisb ( self , N , MODE )
692- }
686+ pub trait VectorCeil {
687+ // same as vec_roundp
688+ unsafe fn vec_ceil ( self ) -> Self ;
693689 }
694690
695691 #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
696- impl VectorRound for vector_double {
697- #[ inline]
698- #[ target_feature( enable = "vector" ) ]
699- unsafe fn vec_round_impl < const N : i32 , const MODE : i32 > ( self ) -> Self {
700- vfidb ( self , N , MODE )
701- }
692+ pub trait VectorFloor {
693+ // same as vec_roundm
694+ unsafe fn vec_floor ( self ) -> Self ;
702695 }
696+
697+ impl_vec_trait ! { [ VectorTrunc vec_trunc] simd_trunc ( vector_float) }
698+ impl_vec_trait ! { [ VectorTrunc vec_trunc] simd_trunc ( vector_double) }
699+
700+ impl_vec_trait ! { [ VectorCeil vec_ceil] simd_ceil ( vector_float) }
701+ impl_vec_trait ! { [ VectorCeil vec_ceil] simd_ceil ( vector_double) }
702+
703+ impl_vec_trait ! { [ VectorFloor vec_floor] simd_floor ( vector_float) }
704+ impl_vec_trait ! { [ VectorFloor vec_floor] simd_floor ( vector_double) }
703705}
704706
705707/// Vector element-wise addition.
@@ -920,7 +922,7 @@ where
920922#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
921923pub unsafe fn vec_floor < T > ( a : T ) -> T
922924where
923- T : sealed:: VectorRound ,
925+ T : sealed:: VectorFloor ,
924926{
925927 a. vec_floor ( )
926928}
@@ -931,7 +933,7 @@ where
931933#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
932934pub unsafe fn vec_ceil < T > ( a : T ) -> T
933935where
934- T : sealed:: VectorRound ,
936+ T : sealed:: VectorCeil ,
935937{
936938 a. vec_ceil ( )
937939}
@@ -943,7 +945,7 @@ where
943945#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
944946pub unsafe fn vec_trunc < T > ( a : T ) -> T
945947where
946- T : sealed:: VectorRound ,
948+ T : sealed:: VectorTrunc ,
947949{
948950 a. vec_trunc ( )
949951}
@@ -966,7 +968,7 @@ where
966968#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
967969pub unsafe fn vec_roundc < T > ( a : T ) -> T
968970where
969- T : sealed:: VectorRound ,
971+ T : sealed:: VectorRoundc ,
970972{
971973 a. vec_roundc ( )
972974}
@@ -978,7 +980,7 @@ where
978980#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
979981pub unsafe fn vec_roundm < T > ( a : T ) -> T
980982where
981- T : sealed:: VectorRound ,
983+ T : sealed:: VectorFloor ,
982984{
983985 // the IBM docs note
984986 //
@@ -995,7 +997,7 @@ where
995997#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
996998pub unsafe fn vec_roundp < T > ( a : T ) -> T
997999where
998- T : sealed:: VectorRound ,
1000+ T : sealed:: VectorCeil ,
9991001{
10001002 // the IBM docs note
10011003 //
@@ -1012,7 +1014,7 @@ where
10121014#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
10131015pub unsafe fn vec_roundz < T > ( a : T ) -> T
10141016where
1015- T : sealed:: VectorRound ,
1017+ T : sealed:: VectorTrunc ,
10161018{
10171019 // the IBM docs note
10181020 //
@@ -1028,7 +1030,7 @@ where
10281030#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
10291031pub unsafe fn vec_rint < T > ( a : T ) -> T
10301032where
1031- T : sealed:: VectorRound ,
1033+ T : sealed:: VectorRint ,
10321034{
10331035 a. vec_rint ( )
10341036}
@@ -1304,11 +1306,16 @@ mod tests {
13041306 [ 1.0 , 1.0 ]
13051307 }
13061308
1307- // FIXME(vector-enhancements-1)
1308- // test_vec_1! { test_vec_round_f32, vec_round, f32x4,
1309- // [],
1310- // []
1311- // }
1309+ test_vec_1 ! { test_vec_round_f32, vec_round, f32x4,
1310+ [ 0.1 , 0.5 , 0.6 , 0.9 ] ,
1311+ [ 0.0 , 0.0 , 1.0 , 1.0 ]
1312+ }
1313+
1314+ test_vec_1 ! { test_vec_round_f32_even_odd, vec_round, f32x4,
1315+ [ 0.5 , 1.5 , 2.5 , 3.5 ] ,
1316+ [ 0.0 , 2.0 , 2.0 , 4.0 ]
1317+ }
1318+
13121319 test_vec_1 ! { test_vec_round_f64_1, vec_round, f64x2,
13131320 [ 0.1 , 0.5 ] ,
13141321 [ 0.0 , 0.0 ]
@@ -1318,11 +1325,16 @@ mod tests {
13181325 [ 1.0 , 1.0 ]
13191326 }
13201327
1321- // FIXME(vector-enhancements-1)
1322- // test_vec_1! { test_vec_roundc_f32, vec_roundc, f32x4,
1323- // [],
1324- // []
1325- // }
1328+ test_vec_1 ! { test_vec_roundc_f32, vec_roundc, f32x4,
1329+ [ 0.1 , 0.5 , 0.6 , 0.9 ] ,
1330+ [ 0.0 , 0.0 , 1.0 , 1.0 ]
1331+ }
1332+
1333+ test_vec_1 ! { test_vec_roundc_f32_even_odd, vec_roundc, f32x4,
1334+ [ 0.5 , 1.5 , 2.5 , 3.5 ] ,
1335+ [ 0.0 , 2.0 , 2.0 , 4.0 ]
1336+ }
1337+
13261338 test_vec_1 ! { test_vec_roundc_f64_1, vec_roundc, f64x2,
13271339 [ 0.1 , 0.5 ] ,
13281340 [ 0.0 , 0.0 ]
@@ -1332,11 +1344,16 @@ mod tests {
13321344 [ 1.0 , 1.0 ]
13331345 }
13341346
1335- // FIXME(vector-enhancements-1)
1336- // test_vec_1! { test_vec_rint_f32, vec_rint, f32x4,
1337- // [],
1338- // []
1339- // }
1347+ test_vec_1 ! { test_vec_rint_f32, vec_rint, f32x4,
1348+ [ 0.1 , 0.5 , 0.6 , 0.9 ] ,
1349+ [ 0.0 , 0.0 , 1.0 , 1.0 ]
1350+ }
1351+
1352+ test_vec_1 ! { test_vec_rint_f32_even_odd, vec_rint, f32x4,
1353+ [ 0.5 , 1.5 , 2.5 , 3.5 ] ,
1354+ [ 0.0 , 2.0 , 2.0 , 4.0 ]
1355+ }
1356+
13401357 test_vec_1 ! { test_vec_rint_f64_1, vec_rint, f64x2,
13411358 [ 0.1 , 0.5 ] ,
13421359 [ 0.0 , 0.0 ]
0 commit comments