-
Notifications
You must be signed in to change notification settings - Fork 276
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
Add SSE2 trivial aliases and conversions. #165
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1795,6 +1795,13 @@ pub unsafe fn _mm_cvtsd_si64(a: f64x2) -> i64 { | |
cvtsd2si64(a) | ||
} | ||
|
||
/// Alias for [`_mm_cvtsd_si64`](fn._mm_cvtsd_si64_ss.html). | ||
#[cfg(target_arch = "x86_64")] | ||
#[inline(always)] | ||
#[target_feature = "+sse2"] | ||
#[cfg_attr(test, assert_instr(cvtsd2si))] | ||
pub unsafe fn _mm_cvtsd_si64x(a: f64x2) -> i64 { _mm_cvtsd_si64(a) } | ||
|
||
/// Convert the lower double-precision (64-bit) floating-point element in `b` | ||
/// to a single-precision (32-bit) floating-point element, store the result in | ||
/// 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 { | |
cvtsd2ss(a, b) | ||
} | ||
|
||
/// Return the lower double-precision (64-bit) floating-point element of "a". | ||
#[inline(always)] | ||
#[target_feature = "+sse2"] | ||
// no particular instruction to test | ||
pub unsafe fn _mm_cvtsd_f64(a: f64x2) -> f64 { | ||
a.extract(0) | ||
} | ||
|
||
/// Convert the lower single-precision (32-bit) floating-point element in `b` | ||
/// to a double-precision (64-bit) floating-point element, store the result in | ||
/// 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 { | |
cvttsd2si64(a) | ||
} | ||
|
||
/// Alias for [`_mm_cvttsd_si64`](fn._mm_cvttsd_si64_ss.html). | ||
#[cfg(target_arch = "x86_64")] | ||
#[inline(always)] | ||
#[target_feature = "+sse2"] | ||
#[cfg_attr(test, assert_instr(cvttsd2si))] | ||
pub unsafe fn _mm_cvttsd_si64x(a: f64x2) -> i64 { _mm_cvttsd_si64(a) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test for this please? I know it's an alias, but we should try to cover the full public API. |
||
|
||
/// Convert packed single-precision (32-bit) floating-point elements in `a` to | ||
/// packed 32-bit integers with truncation. | ||
#[inline(always)] | ||
|
@@ -3989,8 +4011,14 @@ mod tests { | |
|
||
let r = sse2::_mm_cvtsd_si64(f64x2::new(f64::MAX, f64::MIN)); | ||
assert_eq!(r, i64::MIN); | ||
} | ||
|
||
#[cfg(target_arch = "x86_64")] | ||
#[simd_test = "sse2"] | ||
unsafe fn _mm_cvtsd_si64x() { | ||
use std::{f64, i64}; | ||
|
||
let r = sse2::_mm_cvtsd_si64(f64x2::new(f64::NAN, f64::NAN)); | ||
let r = sse2::_mm_cvtsd_si64x(f64x2::new(f64::NAN, f64::NAN)); | ||
assert_eq!(r, i64::MIN); | ||
} | ||
|
||
|
@@ -4022,6 +4050,12 @@ mod tests { | |
); | ||
} | ||
|
||
#[simd_test = "sse2"] | ||
unsafe fn _mm_cvtsd_f64() { | ||
let r = sse2::_mm_cvtsd_f64(f64x2::new(-1.1, 2.2)); | ||
assert_eq!(r, -1.1); | ||
} | ||
|
||
#[simd_test = "sse2"] | ||
unsafe fn _mm_cvtss_sd() { | ||
use std::{f32, f64}; | ||
|
@@ -4068,14 +4102,18 @@ mod tests { | |
#[cfg(target_arch = "x86_64")] | ||
#[simd_test = "sse2"] | ||
unsafe fn _mm_cvttsd_si64() { | ||
use std::{f64, i64}; | ||
|
||
let a = f64x2::new(-1.1, 2.2); | ||
let r = sse2::_mm_cvttsd_si64(a); | ||
assert_eq!(r, -1_i64); | ||
} | ||
|
||
#[cfg(target_arch = "x86_64")] | ||
#[simd_test = "sse2"] | ||
unsafe fn _mm_cvttsd_si64x() { | ||
use std::{f64, i64}; | ||
|
||
let a = f64x2::new(f64::NEG_INFINITY, f64::NAN); | ||
let r = sse2::_mm_cvttsd_si64(a); | ||
let r = sse2::_mm_cvttsd_si64x(a); | ||
assert_eq!(r, i64::MIN); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for this please? I know it's an alias, but we should try to cover the full public API.