@@ -2889,6 +2889,65 @@ mod sealed {
2889
2889
}
2890
2890
}
2891
2891
2892
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2893
+ pub trait VectorCompare {
2894
+ unsafe fn vec_all_lt ( self , other : Self ) -> i32 ;
2895
+ unsafe fn vec_all_le ( self , other : Self ) -> i32 ;
2896
+ unsafe fn vec_all_gt ( self , other : Self ) -> i32 ;
2897
+ unsafe fn vec_all_ge ( self , other : Self ) -> i32 ;
2898
+ }
2899
+
2900
+ // NOTE: this implementation is currently non-optimal, but it does work for floats even with
2901
+ // only `vector` enabled.
2902
+ //
2903
+ // - https://github.com/llvm/llvm-project/issues/129434
2904
+ // - https://github.com/llvm/llvm-project/issues/130424
2905
+ macro_rules! impl_vec_compare {
2906
+ ( $( $ty: ident) * ) => {
2907
+ $(
2908
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2909
+ impl VectorCompare for $ty {
2910
+ #[ inline]
2911
+ #[ target_feature( enable = "vector" ) ]
2912
+ unsafe fn vec_all_lt( self , other: Self ) -> i32 {
2913
+ simd_reduce_all( simd_lt:: <_, t_b!( $ty) >( self , other) ) as i32
2914
+ }
2915
+ #[ inline]
2916
+ #[ target_feature( enable = "vector" ) ]
2917
+ unsafe fn vec_all_le( self , other: Self ) -> i32 {
2918
+ simd_reduce_all( simd_le:: <_, t_b!( $ty) >( self , other) ) as i32
2919
+ }
2920
+ #[ inline]
2921
+ #[ target_feature( enable = "vector" ) ]
2922
+ unsafe fn vec_all_gt( self , other: Self ) -> i32 {
2923
+ simd_reduce_all( simd_gt:: <_, t_b!( $ty) >( self , other) ) as i32
2924
+ }
2925
+ #[ inline]
2926
+ #[ target_feature( enable = "vector" ) ]
2927
+ unsafe fn vec_all_ge( self , other: Self ) -> i32 {
2928
+ simd_reduce_all( simd_ge:: <_, t_b!( $ty) >( self , other) ) as i32
2929
+ }
2930
+ }
2931
+ ) *
2932
+ }
2933
+ }
2934
+
2935
+ impl_vec_compare ! {
2936
+ vector_signed_char
2937
+ vector_unsigned_char
2938
+
2939
+ vector_signed_short
2940
+ vector_unsigned_short
2941
+
2942
+ vector_signed_int
2943
+ vector_unsigned_int
2944
+ vector_float
2945
+
2946
+ vector_signed_long_long
2947
+ vector_unsigned_long_long
2948
+ vector_double
2949
+ }
2950
+
2892
2951
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2893
2952
pub trait VectorTestMask {
2894
2953
type Mask ;
@@ -5264,6 +5323,166 @@ pub unsafe fn vec_cmpne_or_0_idx_cc<T: sealed::VectorEqualityIdx>(
5264
5323
a. vec_cmpne_or_0_idx_cc ( b, cc)
5265
5324
}
5266
5325
5326
+ /// All Elements Equal
5327
+ #[ inline]
5328
+ #[ target_feature( enable = "vector" ) ]
5329
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5330
+ pub unsafe fn vec_all_eq < T : sealed:: VectorEquality > ( a : T , b : T ) -> i32 {
5331
+ simd_reduce_all ( vec_cmpeq ( a, b) ) as i32 as i32
5332
+ }
5333
+
5334
+ /// All Elements Not Equal
5335
+ #[ inline]
5336
+ #[ target_feature( enable = "vector" ) ]
5337
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5338
+ pub unsafe fn vec_all_ne < T : sealed:: VectorEquality > ( a : T , b : T ) -> i32 {
5339
+ simd_reduce_all ( vec_cmpne ( a, b) ) as i32
5340
+ }
5341
+
5342
+ /// Any Element Equal
5343
+ #[ inline]
5344
+ #[ target_feature( enable = "vector" ) ]
5345
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5346
+ pub unsafe fn vec_any_eq < T : sealed:: VectorEquality > ( a : T , b : T ) -> i32 {
5347
+ simd_reduce_any ( vec_cmpeq ( a, b) ) as i32
5348
+ }
5349
+
5350
+ /// Any Element Not Equal
5351
+ #[ inline]
5352
+ #[ target_feature( enable = "vector" ) ]
5353
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5354
+ pub unsafe fn vec_any_ne < T : sealed:: VectorEquality > ( a : T , b : T ) -> i32 {
5355
+ simd_reduce_any ( vec_cmpne ( a, b) ) as i32
5356
+ }
5357
+
5358
+ /// All Elements Less Than
5359
+ #[ inline]
5360
+ #[ target_feature( enable = "vector" ) ]
5361
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5362
+ pub unsafe fn vec_all_lt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5363
+ a. vec_all_lt ( b)
5364
+ }
5365
+
5366
+ /// All Elements Less Than or Equal
5367
+ #[ inline]
5368
+ #[ target_feature( enable = "vector" ) ]
5369
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5370
+ pub unsafe fn vec_all_le < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5371
+ a. vec_all_le ( b)
5372
+ }
5373
+
5374
+ /// All Elements Greater Than
5375
+ #[ inline]
5376
+ #[ target_feature( enable = "vector" ) ]
5377
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5378
+ pub unsafe fn vec_all_gt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5379
+ a. vec_all_gt ( b)
5380
+ }
5381
+
5382
+ /// All Elements Greater Than or Equal
5383
+ #[ inline]
5384
+ #[ target_feature( enable = "vector" ) ]
5385
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5386
+ pub unsafe fn vec_all_ge < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5387
+ a. vec_all_ge ( b)
5388
+ }
5389
+
5390
+ /// All Elements Not Less Than
5391
+ #[ inline]
5392
+ #[ target_feature( enable = "vector" ) ]
5393
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5394
+ pub unsafe fn vec_all_nlt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5395
+ vec_all_ge ( a, b)
5396
+ }
5397
+
5398
+ /// All Elements Not Less Than or Equal
5399
+ #[ inline]
5400
+ #[ target_feature( enable = "vector" ) ]
5401
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5402
+ pub unsafe fn vec_all_nle < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5403
+ vec_all_gt ( a, b)
5404
+ }
5405
+
5406
+ /// All Elements Not Greater Than
5407
+ #[ inline]
5408
+ #[ target_feature( enable = "vector" ) ]
5409
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5410
+ pub unsafe fn vec_all_ngt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5411
+ vec_all_le ( a, b)
5412
+ }
5413
+
5414
+ /// All Elements Not Greater Than or Equal
5415
+ #[ inline]
5416
+ #[ target_feature( enable = "vector" ) ]
5417
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5418
+ pub unsafe fn vec_all_nge < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5419
+ vec_all_lt ( a, b)
5420
+ }
5421
+
5422
+ /// Any Elements Less Than
5423
+ #[ inline]
5424
+ #[ target_feature( enable = "vector" ) ]
5425
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5426
+ pub unsafe fn vec_any_lt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5427
+ !vec_all_ge ( a, b)
5428
+ }
5429
+
5430
+ /// Any Elements Less Than or Equal
5431
+ #[ inline]
5432
+ #[ target_feature( enable = "vector" ) ]
5433
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5434
+ pub unsafe fn vec_any_le < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5435
+ !vec_all_gt ( a, b)
5436
+ }
5437
+
5438
+ /// Any Elements Greater Than
5439
+ #[ inline]
5440
+ #[ target_feature( enable = "vector" ) ]
5441
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5442
+ pub unsafe fn vec_any_gt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5443
+ !vec_all_le ( a, b)
5444
+ }
5445
+
5446
+ /// Any Elements Greater Than or Equal
5447
+ #[ inline]
5448
+ #[ target_feature( enable = "vector" ) ]
5449
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5450
+ pub unsafe fn vec_any_ge < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5451
+ !vec_all_lt ( a, b)
5452
+ }
5453
+
5454
+ /// Any Elements Not Less Than
5455
+ #[ inline]
5456
+ #[ target_feature( enable = "vector" ) ]
5457
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5458
+ pub unsafe fn vec_any_nlt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5459
+ vec_any_ge ( a, b)
5460
+ }
5461
+
5462
+ /// Any Elements Not Less Than or Equal
5463
+ #[ inline]
5464
+ #[ target_feature( enable = "vector" ) ]
5465
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5466
+ pub unsafe fn vec_any_nle < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5467
+ vec_any_gt ( a, b)
5468
+ }
5469
+
5470
+ /// Any Elements Not Greater Than
5471
+ #[ inline]
5472
+ #[ target_feature( enable = "vector" ) ]
5473
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5474
+ pub unsafe fn vec_any_ngt < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5475
+ vec_any_le ( a, b)
5476
+ }
5477
+
5478
+ /// Any Elements Not Greater Than or Equal
5479
+ #[ inline]
5480
+ #[ target_feature( enable = "vector" ) ]
5481
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
5482
+ pub unsafe fn vec_any_nge < T : sealed:: VectorCompare > ( a : T , b : T ) -> i32 {
5483
+ vec_any_lt ( a, b)
5484
+ }
5485
+
5267
5486
#[ cfg( test) ]
5268
5487
mod tests {
5269
5488
use super :: * ;
0 commit comments