Skip to content

Commit e4c17a7

Browse files
p32bloBurntSushi
authored andcommitted
Add _mm_cvtepi8_epi16
1 parent adc34a3 commit e4c17a7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/x86/sse41.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::mem;
44

55
#[cfg(test)]
66
use stdsimd_test::assert_instr;
7+
use simd_llvm::{simd_cast, simd_shuffle8};
78

89
use v128::*;
910

@@ -259,6 +260,12 @@ pub unsafe fn _mm_cmpeq_epi64(a: i64x2, b: i64x2) -> i64x2 {
259260
a.eq(b)
260261
}
261262

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+
}
262269

263270
/// Returns the dot product of two f64x2 vectors.
264271
///
@@ -756,7 +763,19 @@ mod tests {
756763
let a = i64x2::new(0, 1);
757764
let b = i64x2::new(0, 0);
758765
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);
760779
assert_eq!(r, e);
761780
}
762781

0 commit comments

Comments
 (0)