diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2019-07-27 17:48:24 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2019-07-29 11:03:55 +0200 |
| commit | 7fdd058c609e9cc727b44a63fd4d9d1ad3cef206 (patch) | |
| tree | 1306021ca8272bdb8f87332d308712e20474872e /example/std_example.rs | |
| parent | 3f7660788042796773fd12e80dccd9af997f7242 (diff) | |
| download | rust-7fdd058c609e9cc727b44a63fd4d9d1ad3cef206.tar.gz rust-7fdd058c609e9cc727b44a63fd4d9d1ad3cef206.zip | |
Emulate some simd intrinsics
Diffstat (limited to 'example/std_example.rs')
| -rw-r--r-- | example/std_example.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/example/std_example.rs b/example/std_example.rs index 2a9df999559..7deaddd7df7 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -3,6 +3,7 @@ use std::io::Write; use std::intrinsics; + fn main() { let _ = ::std::iter::repeat('a' as u8).take(10).collect::<Vec<_>>(); let stderr = ::std::io::stderr(); @@ -43,6 +44,21 @@ fn main() { assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 >> 64, 0xFEDCBA98765432u128); assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128); assert_eq!(353985398u128 * 932490u128, 330087843781020u128); + + unsafe { + test_simd(); + } +} + +#[target_feature(enable = "sse2")] +unsafe fn test_simd() { + use std::arch::x86_64::*; + + let x = _mm_setzero_si128(); + let y = _mm_set1_epi16(7); + let or = _mm_or_si128(x, y); + + assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 7]); } #[derive(PartialEq)] |
