Skip to content

Commit f815110

Browse files
committed
Add SSE2 trivial aliases and conversions.
`_mm_cvtsd_f64`, `_mm_cvtsd_si64x` and `_mm_cvttsd_si64x`. See #40.
1 parent 46d64f0 commit f815110

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/x86/sse2.rs

+28
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,13 @@ pub unsafe fn _mm_cvtsd_si64(a: f64x2) -> i64 {
17951795
cvtsd2si64(a)
17961796
}
17971797

1798+
/// Alias for [`_mm_cvtsd_si64`](fn._mm_cvtsd_si64_ss.html).
1799+
#[cfg(target_arch = "x86_64")]
1800+
#[inline(always)]
1801+
#[target_feature = "+sse2"]
1802+
#[cfg_attr(test, assert_instr(cvtsd2si))]
1803+
pub unsafe fn _mm_cvtsd_si64x(a: f64x2) -> i64 { _mm_cvtsd_si64(a) }
1804+
17981805
/// Convert the lower double-precision (64-bit) floating-point element in `b`
17991806
/// to a single-precision (32-bit) floating-point element, store the result in
18001807
/// the lower element of the return value, and copy the upper element from `a`
@@ -1806,6 +1813,14 @@ pub unsafe fn _mm_cvtsd_ss(a: f32x4, b: f64x2) -> f32x4 {
18061813
cvtsd2ss(a, b)
18071814
}
18081815

1816+
/// Return the lower double-precision (64-bit) floating-point element of "a".
1817+
#[inline(always)]
1818+
#[target_feature = "+sse2"]
1819+
// no particular instruction to test
1820+
pub unsafe fn _mm_cvtsd_f64(a: f64x2) -> f64 {
1821+
a.extract(0)
1822+
}
1823+
18091824
/// Convert the lower single-precision (32-bit) floating-point element in `b`
18101825
/// to a double-precision (64-bit) floating-point element, store the result in
18111826
/// the lower element of the return value, and copy the upper element from `a`
@@ -1845,6 +1860,13 @@ pub unsafe fn _mm_cvttsd_si64(a: f64x2) -> i64 {
18451860
cvttsd2si64(a)
18461861
}
18471862

1863+
/// Alias for [`_mm_cvttsd_si64`](fn._mm_cvttsd_si64_ss.html).
1864+
#[cfg(target_arch = "x86_64")]
1865+
#[inline(always)]
1866+
#[target_feature = "+sse2"]
1867+
#[cfg_attr(test, assert_instr(cvttsd2si))]
1868+
pub unsafe fn _mm_cvttsd_si64x(a: f64x2) -> i64 { _mm_cvttsd_si64(a) }
1869+
18481870
/// Convert packed single-precision (32-bit) floating-point elements in `a` to
18491871
/// packed 32-bit integers with truncation.
18501872
#[inline(always)]
@@ -4022,6 +4044,12 @@ mod tests {
40224044
);
40234045
}
40244046

4047+
#[simd_test = "sse2"]
4048+
unsafe fn _mm_cvtsd_f64() {
4049+
let r = sse2::_mm_cvtsd_f64(f64x2::new(-1.1, 2.2));
4050+
assert_eq!(r, -1.1);
4051+
}
4052+
40254053
#[simd_test = "sse2"]
40264054
unsafe fn _mm_cvtss_sd() {
40274055
use std::{f32, f64};

0 commit comments

Comments
 (0)