@@ -74,9 +74,14 @@ unsafe extern "unadjusted" {
74
74
#[ link_name = "llvm.umin.v4i32" ] fn vmnlf ( a : vector_unsigned_int , b : vector_unsigned_int ) -> vector_unsigned_int ;
75
75
#[ link_name = "llvm.umin.v2i64" ] fn vmnlg ( a : vector_unsigned_long_long , b : vector_unsigned_long_long ) -> vector_unsigned_long_long ;
76
76
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 ;
79
79
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 ;
80
85
}
81
86
82
87
impl_from ! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -636,70 +641,67 @@ mod sealed {
636
641
637
642
impl_vec_trait ! { [ VectorOrc vec_orc] + 2 c ( orc) }
638
643
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
+
639
655
#[ 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
+ }
642
659
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
+ }
648
664
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
+ }
656
669
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) }
663
672
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) }
670
675
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) }
677
678
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 ;
683
683
}
684
684
685
- // FIXME(vector-enhancements-1) apply the right target feature to all methods
686
685
#[ 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 ;
693
689
}
694
690
695
691
#[ 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 ;
702
695
}
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) }
703
705
}
704
706
705
707
/// Vector element-wise addition.
@@ -920,7 +922,7 @@ where
920
922
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
921
923
pub unsafe fn vec_floor < T > ( a : T ) -> T
922
924
where
923
- T : sealed:: VectorRound ,
925
+ T : sealed:: VectorFloor ,
924
926
{
925
927
a. vec_floor ( )
926
928
}
@@ -931,7 +933,7 @@ where
931
933
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
932
934
pub unsafe fn vec_ceil < T > ( a : T ) -> T
933
935
where
934
- T : sealed:: VectorRound ,
936
+ T : sealed:: VectorCeil ,
935
937
{
936
938
a. vec_ceil ( )
937
939
}
@@ -943,7 +945,7 @@ where
943
945
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
944
946
pub unsafe fn vec_trunc < T > ( a : T ) -> T
945
947
where
946
- T : sealed:: VectorRound ,
948
+ T : sealed:: VectorTrunc ,
947
949
{
948
950
a. vec_trunc ( )
949
951
}
@@ -966,7 +968,7 @@ where
966
968
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
967
969
pub unsafe fn vec_roundc < T > ( a : T ) -> T
968
970
where
969
- T : sealed:: VectorRound ,
971
+ T : sealed:: VectorRoundc ,
970
972
{
971
973
a. vec_roundc ( )
972
974
}
@@ -978,7 +980,7 @@ where
978
980
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
979
981
pub unsafe fn vec_roundm < T > ( a : T ) -> T
980
982
where
981
- T : sealed:: VectorRound ,
983
+ T : sealed:: VectorFloor ,
982
984
{
983
985
// the IBM docs note
984
986
//
@@ -995,7 +997,7 @@ where
995
997
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
996
998
pub unsafe fn vec_roundp < T > ( a : T ) -> T
997
999
where
998
- T : sealed:: VectorRound ,
1000
+ T : sealed:: VectorCeil ,
999
1001
{
1000
1002
// the IBM docs note
1001
1003
//
@@ -1012,7 +1014,7 @@ where
1012
1014
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1013
1015
pub unsafe fn vec_roundz < T > ( a : T ) -> T
1014
1016
where
1015
- T : sealed:: VectorRound ,
1017
+ T : sealed:: VectorTrunc ,
1016
1018
{
1017
1019
// the IBM docs note
1018
1020
//
@@ -1028,7 +1030,7 @@ where
1028
1030
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1029
1031
pub unsafe fn vec_rint < T > ( a : T ) -> T
1030
1032
where
1031
- T : sealed:: VectorRound ,
1033
+ T : sealed:: VectorRint ,
1032
1034
{
1033
1035
a. vec_rint ( )
1034
1036
}
@@ -1304,11 +1306,16 @@ mod tests {
1304
1306
[ 1.0 , 1.0 ]
1305
1307
}
1306
1308
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
+
1312
1319
test_vec_1 ! { test_vec_round_f64_1, vec_round, f64x2,
1313
1320
[ 0.1 , 0.5 ] ,
1314
1321
[ 0.0 , 0.0 ]
@@ -1318,11 +1325,16 @@ mod tests {
1318
1325
[ 1.0 , 1.0 ]
1319
1326
}
1320
1327
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
+
1326
1338
test_vec_1 ! { test_vec_roundc_f64_1, vec_roundc, f64x2,
1327
1339
[ 0.1 , 0.5 ] ,
1328
1340
[ 0.0 , 0.0 ]
@@ -1332,11 +1344,16 @@ mod tests {
1332
1344
[ 1.0 , 1.0 ]
1333
1345
}
1334
1346
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
+
1340
1357
test_vec_1 ! { test_vec_rint_f64_1, vec_rint, f64x2,
1341
1358
[ 0.1 , 0.5 ] ,
1342
1359
[ 0.0 , 0.0 ]
0 commit comments