18
18
//! [wiki_avx]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions
19
19
//! [wiki_fma]: https://en.wikipedia.org/wiki/Fused_multiply-accumulate
20
20
21
+ use core:: hint:: unreachable_unchecked;
22
+
21
23
use crate :: core_arch:: { simd:: * , x86:: * } ;
22
24
use crate :: intrinsics:: simd:: * ;
23
25
@@ -178,6 +180,10 @@ pub unsafe fn _mm256_alignr_epi8<const IMM8: i32>(a: __m256i, b: __m256i) -> __m
178
180
let a = a. as_i8x32 ( ) ;
179
181
let b = b. as_i8x32 ( ) ;
180
182
183
+ if IMM8 == 16 {
184
+ return transmute ( a) ;
185
+ }
186
+
181
187
let r: i8x32 = match IMM8 % 16 {
182
188
0 => simd_shuffle ! (
183
189
b,
@@ -307,7 +313,7 @@ pub unsafe fn _mm256_alignr_epi8<const IMM8: i32>(a: __m256i, b: __m256i) -> __m
307
313
52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 ,
308
314
] ,
309
315
) ,
310
- _ => b ,
316
+ _ => unreachable_unchecked ( ) ,
311
317
} ;
312
318
transmute ( r)
313
319
}
@@ -5305,16 +5311,6 @@ mod tests {
5305
5311
) ;
5306
5312
assert_eq_m256i ( r, expected) ;
5307
5313
5308
- #[ rustfmt:: skip]
5309
- let expected = _mm256_setr_epi8 (
5310
- -1 , -2 , -3 , -4 , -5 , -6 , -7 , -8 ,
5311
- -9 , -10 , -11 , -12 , -13 , -14 , -15 , -16 , -17 ,
5312
- -18 , -19 , -20 , -21 , -22 , -23 , -24 , -25 ,
5313
- -26 , -27 , -28 , -29 , -30 , -31 , -32 ,
5314
- ) ;
5315
- let r = _mm256_alignr_epi8 :: < 16 > ( a, b) ;
5316
- assert_eq_m256i ( r, expected) ;
5317
-
5318
5314
let r = _mm256_alignr_epi8 :: < 15 > ( a, b) ;
5319
5315
#[ rustfmt:: skip]
5320
5316
let expected = _mm256_setr_epi8 (
@@ -5327,6 +5323,9 @@ mod tests {
5327
5323
5328
5324
let r = _mm256_alignr_epi8 :: < 0 > ( a, b) ;
5329
5325
assert_eq_m256i ( r, b) ;
5326
+
5327
+ let r = _mm256_alignr_epi8 :: < 16 > ( a, b) ;
5328
+ assert_eq_m256i ( r, a) ;
5330
5329
}
5331
5330
5332
5331
#[ simd_test( enable = "avx2" ) ]
0 commit comments