1//! Advanced Vector Extensions 2 (AVX)
2//!
3//! AVX2 expands most AVX commands to 256-bit wide vector registers and
4//! adds [FMA](https://en.wikipedia.org/wiki/Fused_multiply-accumulate).
5//!
6//! The references are:
7//!
8//! - [Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2:
9//! Instruction Set Reference, A-Z][intel64_ref].
10//! - [AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and
11//! System Instructions][amd64_ref].
12//!
13//! Wikipedia's [AVX][wiki_avx] and [FMA][wiki_fma] pages provide a quick
14//! overview of the instructions available.
15//!
16//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf
17//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf
18//! [wiki_avx]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions
19//! [wiki_fma]: https://en.wikipedia.org/wiki/Fused_multiply-accumulate
20
21use crate::core_arch::x86::*;
22use crate::intrinsics::simd::*;
23
24/// Extracts a 64-bit integer from `a`, selected with `INDEX`.
25///
26/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_extract_epi64)
27#[inline]
28#[target_feature(enable = "avx2")]
29#[rustc_legacy_const_generics(1)]
30// This intrinsic has no corresponding instruction.
31#[stable(feature = "simd_x86", since = "1.27.0")]
32pub unsafe fn _mm256_extract_epi64<const INDEX: i32>(a: __m256i) -> i64 {
33 static_assert_uimm_bits!(INDEX, 2);
34 simd_extract!(a.as_i64x4(), INDEX as u32)
35}
36
37#[cfg(test)]
38mod tests {
39 use crate::core_arch::arch::x86_64::*;
40 use stdarch_test::simd_test;
41
42 #[simd_test(enable = "avx2")]
43 unsafe fn test_mm256_extract_epi64() {
44 let a = _mm256_setr_epi64x(0, 1, 2, 3);
45 let r = _mm256_extract_epi64::<3>(a);
46 assert_eq!(r, 3);
47 }
48}
49