Skip to content

Commit 6d4af47

Browse files
c410-f3rgnzlbg
authored andcommitted
Add _mm_unpackhi_pd and _mm_unpacklo_pd (#184)
* Add _mm_unpackhi_pd and _mm_unpacklo_pd
1 parent 45fff57 commit 6d4af47

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/x86/sse2.rs

+40
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,30 @@ pub unsafe fn _mm_undefined_si128() -> __m128i {
20562056
mem::transmute(i32x4::splat(mem::uninitialized()))
20572057
}
20582058

2059+
/// The resulting `f64x2` element is composed by the low-order values of
2060+
/// the two `f64x2` interleaved input elements, i.e.:
2061+
///
2062+
/// * The [127:64] bits are copied from the [127:64] bits of the second input
2063+
/// * The [63:0] bits are copied from the [127:64] bits of the first input
2064+
#[inline(always)]
2065+
#[target_feature = "+sse2"]
2066+
#[cfg_attr(test, assert_instr(unpckhpd))]
2067+
pub unsafe fn _mm_unpackhi_pd(a: f64x2, b: f64x2) -> f64x2 {
2068+
simd_shuffle2(a, b, [1, 3])
2069+
}
2070+
2071+
/// The resulting `f64x2` element is composed by the high-order values of
2072+
/// the two `f64x2` interleaved input elements, i.e.:
2073+
///
2074+
/// * The [127:64] bits are copied from the [63:0] bits of the second input
2075+
/// * The [63:0] bits are copied from the [63:0] bits of the first input
2076+
#[inline(always)]
2077+
#[target_feature = "+sse2"]
2078+
#[cfg_attr(test, assert_instr(unpcklpd))]
2079+
pub unsafe fn _mm_unpacklo_pd(a: f64x2, b: f64x2) -> f64x2 {
2080+
simd_shuffle2(a, b, [0, 2])
2081+
}
2082+
20592083
#[allow(improper_ctypes)]
20602084
extern "C" {
20612085
#[link_name = "llvm.x86.sse2.pause"]
@@ -4174,4 +4198,20 @@ mod tests {
41744198
let r = sse2::_mm_load_pd1(&d);
41754199
assert_eq!(r, f64x2::new(d, d));
41764200
}
4201+
4202+
#[simd_test = "sse2"]
4203+
unsafe fn _mm_unpackhi_pd() {
4204+
let a = f64x2::new(1.0, 2.0);
4205+
let b = f64x2::new(3.0, 4.0);
4206+
let r = sse2::_mm_unpackhi_pd(a, b);
4207+
assert_eq!(r, f64x2::new(2.0, 4.0));
4208+
}
4209+
4210+
#[simd_test = "sse2"]
4211+
unsafe fn _mm_unpacklo_pd() {
4212+
let a = f64x2::new(1.0, 2.0);
4213+
let b = f64x2::new(3.0, 4.0);
4214+
let r = sse2::_mm_unpacklo_pd(a, b);
4215+
assert_eq!(r, f64x2::new(1.0, 3.0));
4216+
}
41774217
}

0 commit comments

Comments
 (0)