@@ -4,6 +4,7 @@ use std::mem;
4
4
5
5
#[ cfg( test) ]
6
6
use stdsimd_test:: assert_instr;
7
+ use simd_llvm:: { simd_cast, simd_shuffle8} ;
7
8
8
9
use v128:: * ;
9
10
@@ -259,6 +260,12 @@ pub unsafe fn _mm_cmpeq_epi64(a: i64x2, b: i64x2) -> i64x2 {
259
260
a. eq ( b)
260
261
}
261
262
263
+ /// Sign extend packed 8-bit integers in a to packed 16-bit integers
264
+ #[ target_feature = "+sse4.1" ]
265
+ #[ cfg_attr( test, assert_instr( pmovsxbw) ) ]
266
+ pub unsafe fn _mm_cvtepi8_epi16 ( a : i8x16 ) -> i16x8 {
267
+ simd_cast :: < :: v64:: i8x8 , _ > ( simd_shuffle8 ( a, a, [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ) )
268
+ }
262
269
263
270
/// Returns the dot product of two f64x2 vectors.
264
271
///
@@ -756,7 +763,19 @@ mod tests {
756
763
let a = i64x2:: new ( 0 , 1 ) ;
757
764
let b = i64x2:: new ( 0 , 0 ) ;
758
765
let r = sse41:: _mm_cmpeq_epi64 ( a, b) ;
759
- let e = i64x2:: new ( 0xFFFFFFFFFFFFFFFF , 0x0 ) ;
766
+ let e = i64x2:: new ( -1 , 0 ) ;
767
+ assert_eq ! ( r, e) ;
768
+ }
769
+
770
+ #[ simd_test = "sse4.1" ]
771
+ unsafe fn _mm_cvtepi8_epi16 ( ) {
772
+ let a = i8x16:: splat ( 10 ) ;
773
+ let r = sse41:: _mm_cvtepi8_epi16 ( a) ;
774
+ let e = i16x8:: splat ( 10 ) ;
775
+ assert_eq ! ( r, e) ;
776
+ let a = i8x16:: splat ( -10 ) ;
777
+ let r = sse41:: _mm_cvtepi8_epi16 ( a) ;
778
+ let e = i16x8:: splat ( -10 ) ;
760
779
assert_eq ! ( r, e) ;
761
780
}
762
781
0 commit comments