@@ -506,6 +506,31 @@ mod sealed {
506
506
impl_vec_trait ! { [ VectorAbs vec_abs] vec_abs_f32 ( vector_float) }
507
507
impl_vec_trait ! { [ VectorAbs vec_abs] vec_abs_f64 ( vector_double) }
508
508
509
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
510
+ pub trait VectorNabs {
511
+ unsafe fn vec_nabs ( self ) -> Self ;
512
+ }
513
+
514
+ #[ inline]
515
+ #[ target_feature( enable = "vector" ) ]
516
+ #[ cfg_attr(
517
+ all( test, target_feature = "vector-enhancements-1" ) ,
518
+ assert_instr( vflnsb)
519
+ ) ]
520
+ unsafe fn vec_nabs_f32 ( a : vector_float ) -> vector_float {
521
+ simd_neg ( simd_fabs ( a) )
522
+ }
523
+
524
+ #[ inline]
525
+ #[ target_feature( enable = "vector" ) ]
526
+ #[ cfg_attr( test, assert_instr( vflndb) ) ]
527
+ unsafe fn vec_nabs_f64 ( a : vector_double ) -> vector_double {
528
+ simd_neg ( simd_fabs ( a) )
529
+ }
530
+
531
+ impl_vec_trait ! { [ VectorNabs vec_nabs] vec_nabs_f32 ( vector_float) }
532
+ impl_vec_trait ! { [ VectorNabs vec_nabs] vec_nabs_f64 ( vector_double) }
533
+
509
534
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
510
535
pub trait VectorSplats < Output > {
511
536
unsafe fn vec_splats ( self ) -> Output ;
@@ -1528,6 +1553,17 @@ where
1528
1553
a. vec_abs ( )
1529
1554
}
1530
1555
1556
+ /// Vector negative abs.
1557
+ #[ inline]
1558
+ #[ target_feature( enable = "vector" ) ]
1559
+ #[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
1560
+ pub unsafe fn vec_nabs < T > ( a : T ) -> T
1561
+ where
1562
+ T : sealed:: VectorNabs ,
1563
+ {
1564
+ a. vec_nabs ( )
1565
+ }
1566
+
1531
1567
/// Vector splats.
1532
1568
#[ inline]
1533
1569
#[ target_feature( enable = "vector" ) ]
@@ -2351,6 +2387,10 @@ mod tests {
2351
2387
test_vec_abs ! { test_vec_abs_f32, f32x4, -42f32 , 42f32 }
2352
2388
test_vec_abs ! { test_vec_abs_f64, f64x2, -42f64 , 42f64 }
2353
2389
2390
+ test_vec_1 ! { test_vec_nabs, vec_nabs, f32x4,
2391
+ [ core:: f32 :: consts:: PI , 1.0 , 0.0 , -1.0 ] ,
2392
+ [ -core:: f32 :: consts:: PI , -1.0 , 0.0 , -1.0 ] }
2393
+
2354
2394
test_vec_2 ! { test_vec_andc, vec_andc, i32x4,
2355
2395
[ 0b11001100 , 0b11001100 , 0b11001100 , 0b11001100 ] ,
2356
2396
[ 0b00110011 , 0b11110011 , 0b00001100 , 0b10000000 ] ,
0 commit comments