Skip to content

Commit 0b1f0e9

Browse files
committed
Adds _mm_cvtsi32_si64 and _mm_cvsi64_si32 MMX intrinsics
1 parent 8ab4bf1 commit 0b1f0e9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

coresimd/x86/mmx.rs

+30
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,22 @@ pub unsafe fn _m_empty() {
456456
emms()
457457
}
458458

459+
/// Copy 32-bit integer `a` to the lower elements of the return value, and zero
460+
/// the upper element of the return value.
461+
#[inline]
462+
#[target_feature(enable = "mmx")]
463+
pub unsafe fn _mm_cvtsi32_si64(a: i32) -> __m64 {
464+
mem::transmute(i32x2::new(a, 0))
465+
}
466+
467+
/// Return the lower 32-bit integer in `a`.
468+
#[inline]
469+
#[target_feature(enable = "mmx")]
470+
pub unsafe fn _mm_cvtsi64_si32(a: __m64) -> i32 {
471+
let r: i32x2 = mem::transmute(a);
472+
r.0
473+
}
474+
459475
#[allow(improper_ctypes)]
460476
extern "C" {
461477
#[link_name = "llvm.x86.mmx.padd.b"]
@@ -761,4 +777,18 @@ mod tests {
761777
unsafe fn test_m_empty() {
762778
_m_empty();
763779
}
780+
781+
#[simd_test(enable = "mmx")]
782+
unsafe fn test_mm_cvtsi32_si64() {
783+
let a = _mm_cvtsi32_si64(42);
784+
let b = _mm_setr_pi32(42, 0);
785+
assert_eq_m64(a, b);
786+
}
787+
788+
#[simd_test(enable = "mmx")]
789+
unsafe fn test_mm_cvtsi64_si32() {
790+
let a = _mm_setr_pi32(42, 666);
791+
let b = _mm_cvtsi64_si32(a);
792+
assert_eq!(b, 42);
793+
}
764794
}

0 commit comments

Comments
 (0)