@@ -94,8 +94,6 @@ unsafe extern "unadjusted" {
94
94
#[ link_name = "llvm.s390.vsrlb" ] fn vsrlb ( a : vector_signed_char , b : vector_signed_char ) -> vector_signed_char ;
95
95
#[ link_name = "llvm.s390.vslb" ] fn vslb ( a : vector_signed_char , b : vector_signed_char ) -> vector_signed_char ;
96
96
97
- #[ link_name = "llvm.s390.vsldb" ] fn vsldb ( a : i8x16 , b : i8x16 , c : u32 ) -> i8x16 ;
98
- #[ link_name = "llvm.s390.vsld" ] fn vsld ( a : i8x16 , b : i8x16 , c : u32 ) -> i8x16 ;
99
97
#[ link_name = "llvm.s390.vsrd" ] fn vsrd ( a : i8x16 , b : i8x16 , c : u32 ) -> i8x16 ;
100
98
101
99
#[ link_name = "llvm.s390.verimb" ] fn verimb ( a : vector_signed_char , b : vector_signed_char , c : vector_signed_char , d : i32 ) -> vector_signed_char ;
@@ -3484,10 +3482,44 @@ mod sealed {
3484
3482
unsafe fn vec_sldb < const C : u32 > ( self , b : Self ) -> Self ;
3485
3483
}
3486
3484
3487
- // FIXME(llvm) https://github.com/llvm/llvm-project/issues/129955
3488
- // ideally we could implement this in terms of llvm.fshl.i128
3489
- // #[link_name = "llvm.fshl.i128"] fn fshl_i128(a: u128, b: u128, c: u128) -> u128;
3490
- // transmute(fshl_i128(transmute(a), transmute(b), const { C * 8 } ))
3485
+ #[ inline]
3486
+ #[ target_feature( enable = "vector" ) ]
3487
+ #[ cfg_attr( test, assert_instr( vsldb) ) ]
3488
+ unsafe fn test_vec_sld ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_int {
3489
+ a. vec_sld :: < 13 > ( b)
3490
+ }
3491
+
3492
+ #[ inline]
3493
+ #[ target_feature( enable = "vector" ) ]
3494
+ #[ cfg_attr( test, assert_instr( vsldb) ) ]
3495
+ unsafe fn test_vec_sldw ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_int {
3496
+ a. vec_sldw :: < 3 > ( b)
3497
+ }
3498
+
3499
+ #[ inline]
3500
+ #[ target_feature( enable = "vector-enhancements-2" ) ]
3501
+ #[ cfg_attr( test, assert_instr( vsld) ) ]
3502
+ unsafe fn test_vec_sldb ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_int {
3503
+ a. vec_sldb :: < 7 > ( b)
3504
+ }
3505
+
3506
+ #[ inline]
3507
+ #[ target_feature( enable = "vector-enhancements-2" ) ]
3508
+ #[ cfg_attr( test, assert_instr( vsrd) ) ]
3509
+ unsafe fn test_vec_srdb ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_int {
3510
+ a. vec_srdb :: < 7 > ( b)
3511
+ }
3512
+
3513
+ unsafe fn funnel_shl_u128 ( a : u128 , b : u128 , c : u128 ) -> u128 {
3514
+ #[ repr( simd) ]
3515
+ struct Single ( [ u128 ; 1 ] ) ;
3516
+
3517
+ transmute ( simd_funnel_shl :: < Single > (
3518
+ transmute ( a) ,
3519
+ transmute ( b) ,
3520
+ transmute ( c) ,
3521
+ ) )
3522
+ }
3491
3523
3492
3524
macro_rules! impl_vec_sld {
3493
3525
( $( $ty: ident) * ) => {
@@ -3498,21 +3530,21 @@ mod sealed {
3498
3530
#[ target_feature( enable = "vector" ) ]
3499
3531
unsafe fn vec_sld<const C : u32 >( self , b: Self ) -> Self {
3500
3532
static_assert_uimm_bits!( C , 4 ) ;
3501
- transmute( vsldb ( transmute( self ) , transmute( b) , C ) )
3533
+ transmute( funnel_shl_u128 ( transmute( self ) , transmute( b) , const { C as u128 * 8 } ) )
3502
3534
}
3503
3535
3504
3536
#[ inline]
3505
3537
#[ target_feature( enable = "vector" ) ]
3506
3538
unsafe fn vec_sldw<const C : u32 >( self , b: Self ) -> Self {
3507
3539
static_assert_uimm_bits!( C , 2 ) ;
3508
- transmute( vsldb ( transmute( self ) , transmute( b) , const { 4 * C } ) )
3540
+ transmute( funnel_shl_u128 ( transmute( self ) , transmute( b) , const { C as u128 * 4 * 8 } ) )
3509
3541
}
3510
3542
3511
3543
#[ inline]
3512
3544
#[ target_feature( enable = "vector-enhancements-2" ) ]
3513
3545
unsafe fn vec_sldb<const C : u32 >( self , b: Self ) -> Self {
3514
3546
static_assert_uimm_bits!( C , 3 ) ;
3515
- transmute( vsld ( transmute( self ) , transmute( b) , C ) )
3547
+ transmute( funnel_shl_u128 ( transmute( self ) , transmute( b) , const { C as u128 } ) )
3516
3548
}
3517
3549
}
3518
3550
@@ -3523,6 +3555,11 @@ mod sealed {
3523
3555
unsafe fn vec_srdb<const C : u32 >( self , b: Self ) -> Self {
3524
3556
static_assert_uimm_bits!( C , 3 ) ;
3525
3557
transmute( vsrd( transmute( self ) , transmute( b) , C ) )
3558
+ // FIXME(llvm): https://github.com/llvm/llvm-project/issues/129955#issuecomment-3207488190
3559
+ // LLVM currently rewrites `fshr` to `fshl`, and the logic in the s390x
3560
+ // backend cannot deal with that yet.
3561
+ // #[link_name = "llvm.fshr.i128"] fn fshr_i128(a: u128, b: u128, c: u128) -> u128;
3562
+ // transmute(fshr_i128(transmute(self), transmute(b), const { C as u128 }))
3526
3563
}
3527
3564
}
3528
3565
) *
0 commit comments