@@ -181,14 +181,6 @@ unsafe extern "unadjusted" {
181
181
182
182
#[ link_name = "llvm.s390.vcksm" ] fn vcksm ( a : vector_unsigned_int , b : vector_unsigned_int ) -> vector_unsigned_int ;
183
183
184
- #[ link_name = "llvm.s390.vmeb" ] fn vmeb ( a : vector_signed_char , b : vector_signed_char ) -> vector_signed_short ;
185
- #[ link_name = "llvm.s390.vmeh" ] fn vmeh ( a : vector_signed_short , b : vector_signed_short ) -> vector_signed_int ;
186
- #[ link_name = "llvm.s390.vmef" ] fn vmef ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_long_long ;
187
-
188
- #[ link_name = "llvm.s390.vmleb" ] fn vmleb ( a : vector_unsigned_char , b : vector_unsigned_char ) -> vector_unsigned_short ;
189
- #[ link_name = "llvm.s390.vmleh" ] fn vmleh ( a : vector_unsigned_short , b : vector_unsigned_short ) -> vector_unsigned_int ;
190
- #[ link_name = "llvm.s390.vmlef" ] fn vmlef ( a : vector_unsigned_int , b : vector_unsigned_int ) -> vector_unsigned_long_long ;
191
-
192
184
#[ link_name = "llvm.s390.vmob" ] fn vmob ( a : vector_signed_char , b : vector_signed_char ) -> vector_signed_short ;
193
185
#[ link_name = "llvm.s390.vmoh" ] fn vmoh ( a : vector_signed_short , b : vector_signed_short ) -> vector_signed_int ;
194
186
#[ link_name = "llvm.s390.vmof" ] fn vmof ( a : vector_signed_int , b : vector_signed_int ) -> vector_signed_long_long ;
@@ -372,6 +364,19 @@ impl<const N: usize> ShuffleMask<N> {
372
364
ShuffleMask ( mask)
373
365
}
374
366
367
+ const fn even ( ) -> Self {
368
+ let mut mask = [ 0 ; N ] ;
369
+ let mut i = 0 ;
370
+ let mut index = 0 ;
371
+ while index < N {
372
+ mask[ index] = i as u32 ;
373
+
374
+ i += 2 ;
375
+ index += 1 ;
376
+ }
377
+ ShuffleMask ( mask)
378
+ }
379
+
375
380
const fn pack ( ) -> Self {
376
381
let mut mask = [ 0 ; N ] ;
377
382
let mut i = 1 ;
@@ -2642,40 +2647,44 @@ mod sealed {
2642
2647
unsafe fn vec_mule ( self , b : Self ) -> Result ;
2643
2648
}
2644
2649
2645
- // FIXME(llvm) sadly this does not yet work https://github.com/llvm/llvm-project/issues/129705
2646
- // #[target_feature(enable = "vector")]
2647
- // #[cfg_attr(test, assert_instr(vmleh))]
2648
- // unsafe fn vec_vmleh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_int {
2649
- // let even_a: vector_unsigned_int = simd_as(simd_shuffle::<_, _, u16x4>(
2650
- // a,
2651
- // a,
2652
- // const { ShuffleMask([0, 2, 4, 6]) },
2653
- // ));
2654
- //
2655
- // let even_b: vector_unsigned_int = simd_as(simd_shuffle::<_, _, u16x4>(
2656
- // b,
2657
- // b,
2658
- // const { ShuffleMask([0, 2, 4, 6]) },
2659
- // ));
2660
- //
2661
- // simd_mul(even_a, even_b)
2662
- // }
2650
+ macro_rules! impl_vec_mule {
2651
+ ( $instr: ident $src: ident $shuffled: ident $dst: ident $width: literal) => {
2652
+ #[ inline]
2653
+ #[ target_feature( enable = "vector" ) ]
2654
+ #[ cfg_attr( test, assert_instr( $instr) ) ]
2655
+ unsafe fn $instr( a: $src, b: $src) -> $dst {
2656
+ let even_a: $dst = simd_as( simd_shuffle:: <_, _, $shuffled>(
2657
+ a,
2658
+ a,
2659
+ const { ShuffleMask :: <$width>:: even( ) } ,
2660
+ ) ) ;
2661
+
2662
+ let even_b: $dst = simd_as( simd_shuffle:: <_, _, $shuffled>(
2663
+ b,
2664
+ b,
2665
+ const { ShuffleMask :: <$width>:: even( ) } ,
2666
+ ) ) ;
2667
+
2668
+ simd_mul( even_a, even_b)
2669
+ }
2670
+ } ;
2671
+ }
2663
2672
2664
- test_impl ! { vec_vmeb ( a : vector_signed_char, b : vector_signed_char ) -> vector_signed_short [ vmeb , vmeb ] }
2665
- test_impl ! { vec_vmeh ( a : vector_signed_short, b : vector_signed_short ) -> vector_signed_int[ vmeh , vmeh ] }
2666
- test_impl ! { vec_vmef ( a : vector_signed_int, b : vector_signed_int ) -> vector_signed_long_long [ vmef , vmef ] }
2673
+ impl_vec_mule ! { vmeb vector_signed_char i8x8 vector_signed_short 8 }
2674
+ impl_vec_mule ! { vmeh vector_signed_short i16x4 vector_signed_int 4 }
2675
+ impl_vec_mule ! { vmef vector_signed_int i32x2 vector_signed_long_long 2 }
2667
2676
2668
- test_impl ! { vec_vmleb ( a : vector_unsigned_char, b : vector_unsigned_char ) -> vector_unsigned_short [ vmleb , vmleb ] }
2669
- test_impl ! { vec_vmleh ( a : vector_unsigned_short, b : vector_unsigned_short ) -> vector_unsigned_int[ vmleh , vmleh ] }
2670
- test_impl ! { vec_vmlef ( a : vector_unsigned_int, b : vector_unsigned_int ) -> vector_unsigned_long_long [ vmlef , vmlef ] }
2677
+ impl_vec_mule ! { vmleb vector_unsigned_char u8x8 vector_unsigned_short 8 }
2678
+ impl_vec_mule ! { vmleh vector_unsigned_short u16x4 vector_unsigned_int 4 }
2679
+ impl_vec_mule ! { vmlef vector_unsigned_int u32x2 vector_unsigned_long_long 2 }
2671
2680
2672
- impl_mul ! ( [ VectorMule vec_mule] vec_vmeb ( vector_signed_char, vector_signed_char) -> vector_signed_short ) ;
2673
- impl_mul ! ( [ VectorMule vec_mule] vec_vmeh ( vector_signed_short, vector_signed_short) -> vector_signed_int) ;
2674
- impl_mul ! ( [ VectorMule vec_mule] vec_vmef ( vector_signed_int, vector_signed_int) -> vector_signed_long_long ) ;
2681
+ impl_mul ! ( [ VectorMule vec_mule] vmeb ( vector_signed_char, vector_signed_char) -> vector_signed_short ) ;
2682
+ impl_mul ! ( [ VectorMule vec_mule] vmeh ( vector_signed_short, vector_signed_short) -> vector_signed_int) ;
2683
+ impl_mul ! ( [ VectorMule vec_mule] vmef ( vector_signed_int, vector_signed_int) -> vector_signed_long_long ) ;
2675
2684
2676
- impl_mul ! ( [ VectorMule vec_mule] vec_vmleb ( vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_short ) ;
2677
- impl_mul ! ( [ VectorMule vec_mule] vec_vmleh ( vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_int) ;
2678
- impl_mul ! ( [ VectorMule vec_mule] vec_vmlef ( vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_long_long ) ;
2685
+ impl_mul ! ( [ VectorMule vec_mule] vmleb ( vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_short ) ;
2686
+ impl_mul ! ( [ VectorMule vec_mule] vmleh ( vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_int) ;
2687
+ impl_mul ! ( [ VectorMule vec_mule] vmlef ( vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_long_long ) ;
2679
2688
2680
2689
#[ unstable( feature = "stdarch_s390x" , issue = "135681" ) ]
2681
2690
pub trait VectorMulo < Result > {
0 commit comments