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 | |
21 | use crate::core_arch::{simd_llvm::*, x86::*}; |
22 | |
23 | /// Extracts a 64-bit integer from `a`, selected with `INDEX`. |
24 | /// |
25 | /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_extract_epi64) |
26 | #[inline ] |
27 | #[target_feature (enable = "avx2" )] |
28 | #[rustc_legacy_const_generics (1)] |
29 | // This intrinsic has no corresponding instruction. |
30 | #[stable (feature = "simd_x86" , since = "1.27.0" )] |
31 | pub unsafe fn _mm256_extract_epi64<const INDEX: i32>(a: __m256i) -> i64 { |
32 | static_assert_uimm_bits!(INDEX, 2); |
33 | simd_extract(x:a.as_i64x4(), INDEX as u32) |
34 | } |
35 | |
36 | #[cfg (test)] |
37 | mod tests { |
38 | use crate::core_arch::arch::x86_64::*; |
39 | use stdarch_test::simd_test; |
40 | |
41 | #[simd_test(enable = "avx2" )] |
42 | unsafe fn test_mm256_extract_epi64() { |
43 | let a = _mm256_setr_epi64x(0, 1, 2, 3); |
44 | let r = _mm256_extract_epi64::<3>(a); |
45 | assert_eq!(r, 3); |
46 | } |
47 | } |
48 | |