Skip to content

Commit 23c6330

Browse files
mohanrajendranBurntSushi
authored andcommitted
Added _mm_unpackhi_ps function (rust-lang#16)
Added _mm_unpackhi_ps
1 parent 35025db commit 23c6330

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Diff for: .vscode/temp.sql

Whitespace-only changes.

Diff for: TODO.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ sse
155155
* [ ] `_mm_storer_ps`
156156
* [ ] `_mm_move_ss`
157157
* [ ] `_mm_shuffle_ps`
158-
* [ ] `_mm_unpackhi_ps`
158+
* [x] `_mm_unpackhi_ps`
159159
* [ ] `_mm_unpacklo_ps`
160160
* [ ] `_mm_movehl_ps`
161161
* [ ] `_mm_movelh_ps`

Diff for: src/x86/sse.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use simd_llvm::simd_shuffle4;
12
use v128::*;
23

34
/// Return the square root of packed single-precision (32-bit) floating-point
@@ -40,6 +41,14 @@ pub fn _mm_max_ps(a: f32x4, b: f32x4) -> f32x4 {
4041
unsafe { maxps(a, b) }
4142
}
4243

44+
/// Unpack and interleave single-precision (32-bit) floating-point elements
45+
/// from the high half of `a` and `b`;
46+
#[inline(always)]
47+
#[target_feature = "+sse"]
48+
pub fn _mm_unpackhi_ps(a: f32x4, b: f32x4) -> f32x4 {
49+
unsafe { simd_shuffle4(a, b, [2, 6, 3, 7]) }
50+
}
51+
4352
/// Return a mask of the most significant bit of each element in `a`.
4453
///
4554
/// The mask is stored in the 4 least significant bits of the return value.
@@ -116,6 +125,15 @@ mod tests {
116125
assert_eq!(r, f32x4::new(-1.0, 20.0, 0.0, -5.0));
117126
}
118127

128+
#[test]
129+
#[target_feature = "+sse"]
130+
fn _mm_unpackhi_ps() {
131+
let a = f32x4::new(1.0, 2.0, 3.0, 4.0);
132+
let b = f32x4::new(5.0, 6.0, 7.0, 8.0);
133+
let r = sse::_mm_unpackhi_ps(a, b);
134+
assert_eq!(r, f32x4::new(3.0, 7.0, 4.0, 8.0));
135+
}
136+
119137
#[test]
120138
#[target_feature = "+sse"]
121139
fn _mm_movemask_ps() {

0 commit comments

Comments
 (0)