Skip to content
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

[x86] Add _mm_cvtps_epi32 (cvtps2dq) function #65

Merged
merged 1 commit into from
Sep 28, 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
18 changes: 18 additions & 0 deletions src/x86/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,15 @@ pub unsafe fn _mm_cvtepi32_ps(a: i32x4) -> f32x4 {
cvtdq2ps(a)
}

/// Convert packed single-precision (32-bit) floating-point elements in `a`
/// to packed 32-bit integers.
#[inline(always)]
#[target_feature = "+sse2"]
#[cfg_attr(test, assert_instr(cvtps2dq))]
pub unsafe fn _mm_cvtps_epi32(a: f32x4) -> i32x4 {
cvtps2dq(a)
}

/// Return a vector whose lowest element is `a` and all higher elements are
/// `0`.
#[inline(always)]
Expand Down Expand Up @@ -1819,6 +1828,8 @@ extern {
fn psrlq(a: i64x2, count: i64x2) -> i64x2;
#[link_name = "llvm.x86.sse2.cvtdq2ps"]
fn cvtdq2ps(a: i32x4) -> f32x4;
#[link_name = "llvm.x86.sse2.cvtps2dq"]
fn cvtps2dq(a: f32x4) -> i32x4;
#[link_name = "llvm.x86.sse2.maskmov.dqu"]
fn maskmovdqu(a: i8x16, mask: i8x16, mem_addr: *mut i8);
#[link_name = "llvm.x86.sse2.packsswb.128"]
Expand Down Expand Up @@ -2565,6 +2576,13 @@ mod tests {
assert_eq!(r, f32x4::new(1.0, 2.0, 3.0, 4.0));
}

#[simd_test = "sse2"]
unsafe fn _mm_cvtps_epi32() {
let a = f32x4::new(1.0, 2.0, 3.0, 4.0);
let r = sse2::_mm_cvtps_epi32(a);
assert_eq!(r, i32x4::new(1, 2, 3, 4));
}

#[simd_test = "sse2"]
unsafe fn _mm_cvtsi32_si128() {
let r = sse2::_mm_cvtsi32_si128(5);
Expand Down