Skip to content

Add _mm_unpackhi_pd and _mm_unpacklo_pd #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/x86/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,30 @@ pub unsafe fn _mm_undefined_si128() -> __m128i {
mem::transmute(i32x4::splat(mem::uninitialized()))
}

/// The resulting `f64x2` element is composed by the low-order values of
/// the two `f64x2` interleaved input elements, i.e.:
///
/// * The [127:64] bits are copied from the [127:64] bits of the second input
/// * The [63:0] bits are copied from the [127:64] bits of the first input
#[inline(always)]
#[target_feature = "+sse2"]
#[cfg_attr(test, assert_instr(unpckhpd))]
pub unsafe fn _mm_unpackhi_pd(a: f64x2, b: f64x2) -> f64x2 {
simd_shuffle2(a, b, [1, 3])
}

/// The resulting `f64x2` element is composed by the high-order values of
/// the two `f64x2` interleaved input elements, i.e.:
///
/// * The [127:64] bits are copied from the [63:0] bits of the second input
/// * The [63:0] bits are copied from the [63:0] bits of the first input
#[inline(always)]
#[target_feature = "+sse2"]
#[cfg_attr(test, assert_instr(unpcklpd))]
pub unsafe fn _mm_unpacklo_pd(a: f64x2, b: f64x2) -> f64x2 {
simd_shuffle2(a, b, [0, 2])
}

#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.x86.sse2.pause"]
Expand Down Expand Up @@ -4170,4 +4194,20 @@ mod tests {
let r = sse2::_mm_load_pd1(&d);
assert_eq!(r, f64x2::new(d, d));
}

#[simd_test = "sse2"]
unsafe fn _mm_unpackhi_pd() {
let a = f64x2::new(1.0, 2.0);
let b = f64x2::new(3.0, 4.0);
let r = sse2::_mm_unpackhi_pd(a, b);
assert_eq!(r, f64x2::new(2.0, 4.0));
}

#[simd_test = "sse2"]
unsafe fn _mm_unpacklo_pd() {
let a = f64x2::new(1.0, 2.0);
let b = f64x2::new(3.0, 4.0);
let r = sse2::_mm_unpacklo_pd(a, b);
assert_eq!(r, f64x2::new(1.0, 3.0));
}
}