Skip to content

Add example to _mm_extract_ps #1228

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

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion crates/core_arch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![deny(rust_2018_idioms)]
#![feature(
asm,
const_panic,
custom_inner_attributes,
link_llvm_intrinsics,
platform_intrinsics,
Expand Down
24 changes: 23 additions & 1 deletion crates/core_arch/src/x86/sse41.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,30 @@ pub unsafe fn _mm_blend_ps<const IMM4: i32>(a: __m128, b: __m128) -> __m128 {
}

/// Extracts a single-precision (32-bit) floating-point element from `a`,
/// selected with `IMM8`
/// selected with `IMM8`. The returned `i32` stores the float's bit-pattern,
/// and may be converted back to a floating point number via casting.
///
/// # Example
/// ```rust
/// #[cfg(target_arch = "x86")]
/// #use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
/// #use std::arch::x86_64::*;
/// #fn main() {
/// # if is_x86_feature_detected!("sse4.1") {
/// # #[target_feature(enable = "sse4.1")]
/// # unsafe fn worker() {
/// let mut float_store = vec![1.0, 1.0, 2.0, 3.0];
/// unsafe {
/// let simd_floats = _mm_set_ps(2.5, 5.0, 7.5, 10.0);
/// let x: i32 = _mm_extract_ps::<2>(simd_floats);
/// float_store.push(f32::from_bits(x as u32));
/// }
/// assert_eq!(float_store, vec![1.0, 1.0, 2.0, 3.0, 5.0]);
/// # }
/// # unsafe { worker() }
/// #}
/// ```
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_extract_ps)
#[inline]
#[target_feature(enable = "sse4.1")]
Expand Down