@@ -2493,57 +2493,34 @@ pub unsafe fn _mm256_shuffle_epi32<const MASK: i32>(a: __m256i) -> __m256i {
2493
2493
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_shufflehi_epi16)
2494
2494
#[ inline]
2495
2495
#[ target_feature( enable = "avx2" ) ]
2496
- #[ cfg_attr( test, assert_instr( vpshufhw, imm8 = 9 ) ) ]
2497
- #[ rustc_args_required_const ( 1 ) ]
2496
+ #[ cfg_attr( test, assert_instr( vpshufhw, IMM8 = 9 ) ) ]
2497
+ #[ rustc_legacy_const_generics ( 1 ) ]
2498
2498
#[ stable( feature = "simd_x86" , since = "1.27.0" ) ]
2499
- pub unsafe fn _mm256_shufflehi_epi16 ( a : __m256i , imm8 : i32 ) -> __m256i {
2500
- let imm8 = ( imm8 & 0xFF ) as u8 ;
2499
+ pub unsafe fn _mm256_shufflehi_epi16 < const IMM8 : i32 > ( a : __m256i ) -> __m256i {
2500
+ static_assert_imm8 ! ( IMM8 ) ;
2501
2501
let a = a. as_i16x16 ( ) ;
2502
- macro_rules! shuffle_done {
2503
- ( $x01: expr, $x23: expr, $x45: expr, $x67: expr) => {
2504
- #[ rustfmt:: skip]
2505
- simd_shuffle16( a, a, [
2506
- 0 , 1 , 2 , 3 , 4 +$x01, 4 +$x23, 4 +$x45, 4 +$x67,
2507
- 8 , 9 , 10 , 11 , 12 +$x01, 12 +$x23, 12 +$x45, 12 +$x67
2508
- ] )
2509
- } ;
2510
- }
2511
- macro_rules! shuffle_x67 {
2512
- ( $x01: expr, $x23: expr, $x45: expr) => {
2513
- match ( imm8 >> 6 ) & 0b11 {
2514
- 0b00 => shuffle_done!( $x01, $x23, $x45, 0 ) ,
2515
- 0b01 => shuffle_done!( $x01, $x23, $x45, 1 ) ,
2516
- 0b10 => shuffle_done!( $x01, $x23, $x45, 2 ) ,
2517
- _ => shuffle_done!( $x01, $x23, $x45, 3 ) ,
2518
- }
2519
- } ;
2520
- }
2521
- macro_rules! shuffle_x45 {
2522
- ( $x01: expr, $x23: expr) => {
2523
- match ( imm8 >> 4 ) & 0b11 {
2524
- 0b00 => shuffle_x67!( $x01, $x23, 0 ) ,
2525
- 0b01 => shuffle_x67!( $x01, $x23, 1 ) ,
2526
- 0b10 => shuffle_x67!( $x01, $x23, 2 ) ,
2527
- _ => shuffle_x67!( $x01, $x23, 3 ) ,
2528
- }
2529
- } ;
2530
- }
2531
- macro_rules! shuffle_x23 {
2532
- ( $x01: expr) => {
2533
- match ( imm8 >> 2 ) & 0b11 {
2534
- 0b00 => shuffle_x45!( $x01, 0 ) ,
2535
- 0b01 => shuffle_x45!( $x01, 1 ) ,
2536
- 0b10 => shuffle_x45!( $x01, 2 ) ,
2537
- _ => shuffle_x45!( $x01, 3 ) ,
2538
- }
2539
- } ;
2540
- }
2541
- let r: i16x16 = match imm8 & 0b11 {
2542
- 0b00 => shuffle_x23 ! ( 0 ) ,
2543
- 0b01 => shuffle_x23 ! ( 1 ) ,
2544
- 0b10 => shuffle_x23 ! ( 2 ) ,
2545
- _ => shuffle_x23 ! ( 3 ) ,
2546
- } ;
2502
+ let r: i16x16 = simd_shuffle16 (
2503
+ a,
2504
+ a,
2505
+ [
2506
+ 0 ,
2507
+ 1 ,
2508
+ 2 ,
2509
+ 3 ,
2510
+ 4 + ( IMM8 as u32 & 0b11 ) ,
2511
+ 4 + ( ( IMM8 as u32 >> 2 ) & 0b11 ) ,
2512
+ 4 + ( ( IMM8 as u32 >> 4 ) & 0b11 ) ,
2513
+ 4 + ( ( IMM8 as u32 >> 6 ) & 0b11 ) ,
2514
+ 8 ,
2515
+ 9 ,
2516
+ 10 ,
2517
+ 11 ,
2518
+ 12 + ( IMM8 as u32 & 0b11 ) ,
2519
+ 12 + ( ( IMM8 as u32 >> 2 ) & 0b11 ) ,
2520
+ 12 + ( ( IMM8 as u32 >> 4 ) & 0b11 ) ,
2521
+ 12 + ( ( IMM8 as u32 >> 6 ) & 0b11 ) ,
2522
+ ] ,
2523
+ ) ;
2547
2524
transmute ( r)
2548
2525
}
2549
2526
@@ -4891,7 +4868,7 @@ mod tests {
4891
4868
0 , 1 , 2 , 3 , 44 , 22 , 22 , 11 ,
4892
4869
4 , 5 , 6 , 7 , 88 , 66 , 66 , 55 ,
4893
4870
) ;
4894
- let r = _mm256_shufflehi_epi16 ( a , 0b00_01_01_11 ) ;
4871
+ let r = _mm256_shufflehi_epi16 :: < 0b00_01_01_11 > ( a ) ;
4895
4872
assert_eq_m256i ( r, e) ;
4896
4873
}
4897
4874
0 commit comments