Skip to content

Commit

Permalink
Added _mm_unpackhi_ps function (rust-lang#16)
Browse files Browse the repository at this point in the history
Added _mm_unpackhi_ps
  • Loading branch information
mohanrajendran authored and BurntSushi committed Sep 20, 2017
1 parent 35025db commit 23c6330
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Empty file added .vscode/temp.sql
Empty file.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ sse
* [ ] `_mm_storer_ps`
* [ ] `_mm_move_ss`
* [ ] `_mm_shuffle_ps`
* [ ] `_mm_unpackhi_ps`
* [x] `_mm_unpackhi_ps`
* [ ] `_mm_unpacklo_ps`
* [ ] `_mm_movehl_ps`
* [ ] `_mm_movelh_ps`
Expand Down
18 changes: 18 additions & 0 deletions src/x86/sse.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use simd_llvm::simd_shuffle4;
use v128::*;

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

/// Unpack and interleave single-precision (32-bit) floating-point elements
/// from the high half of `a` and `b`;
#[inline(always)]
#[target_feature = "+sse"]
pub fn _mm_unpackhi_ps(a: f32x4, b: f32x4) -> f32x4 {
unsafe { simd_shuffle4(a, b, [2, 6, 3, 7]) }
}

/// Return a mask of the most significant bit of each element in `a`.
///
/// The mask is stored in the 4 least significant bits of the return value.
Expand Down Expand Up @@ -116,6 +125,15 @@ mod tests {
assert_eq!(r, f32x4::new(-1.0, 20.0, 0.0, -5.0));
}

#[test]
#[target_feature = "+sse"]
fn _mm_unpackhi_ps() {
let a = f32x4::new(1.0, 2.0, 3.0, 4.0);
let b = f32x4::new(5.0, 6.0, 7.0, 8.0);
let r = sse::_mm_unpackhi_ps(a, b);
assert_eq!(r, f32x4::new(3.0, 7.0, 4.0, 8.0));
}

#[test]
#[target_feature = "+sse"]
fn _mm_movemask_ps() {
Expand Down

0 comments on commit 23c6330

Please sign in to comment.