Skip to content

Commit 588e984

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 588e984

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/x86/sse2.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,12 @@ 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+
#[inline(always)]
1800+
#[target_feature = "+sse2"]
1801+
#[cfg_attr(test, assert_instr(cvtsd2si))]
1802+
pub unsafe fn _mm_cvtsd_si64x(a: f64x2) -> i64 { _mm_cvtsd_si64(a) }
1803+
17981804
/// Convert the lower double-precision (64-bit) floating-point element in `b`
17991805
/// to a single-precision (32-bit) floating-point element, store the result in
18001806
/// the lower element of the return value, and copy the upper element from `a`
@@ -1806,6 +1812,14 @@ pub unsafe fn _mm_cvtsd_ss(a: f32x4, b: f64x2) -> f32x4 {
18061812
cvtsd2ss(a, b)
18071813
}
18081814

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

1862+
/// Alias for [`_mm_cvttsd_si64`](fn._mm_cvttsd_si64_ss.html).
1863+
#[inline(always)]
1864+
#[target_feature = "+sse2"]
1865+
#[cfg_attr(test, assert_instr(cvttsd2si))]
1866+
pub unsafe fn _mm_cvttsd_si64x(a: f64x2) -> i64 { _mm_cvttsd_si64(a) }
1867+
18481868
/// Convert packed single-precision (32-bit) floating-point elements in `a` to
18491869
/// packed 32-bit integers with truncation.
18501870
#[inline(always)]
@@ -4022,6 +4042,12 @@ mod tests {
40224042
);
40234043
}
40244044

4045+
#[simd_test = "sse2"]
4046+
unsafe fn _mm_cvtsd_f64() {
4047+
let r = sse2::_mm_cvtsd_f64(f64x2::new(-1.1, 2.2));
4048+
assert_eq!(r, -1.1);
4049+
}
4050+
40254051
#[simd_test = "sse2"]
40264052
unsafe fn _mm_cvtss_sd() {
40274053
use std::{f32, f64};

0 commit comments

Comments
 (0)