|
| 1 | +//! rotate instruction tests |
| 2 | +
|
| 3 | +#![feature(stdsimd)] |
| 4 | +#![feature(proc_macro)] |
| 5 | +#![feature(avx512_target_feature)] |
| 6 | +#![feature(abi_vectorcall)] |
| 7 | + |
| 8 | +extern crate stdsimd_test; |
| 9 | +extern crate stdsimd; |
| 10 | + |
| 11 | +use stdsimd::simd::*; |
| 12 | +use stdsimd_test::assert_instr; |
| 13 | + |
| 14 | +// Verify that supported hardware compiles rotates into single instructions |
| 15 | + |
| 16 | +#[inline] |
| 17 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))] |
| 18 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprorvq))] |
| 19 | +unsafe fn rotate_right_variable(x: u64x8) -> u64x8 { |
| 20 | + x.rotate_right(u64x8::new(0, 1, 2, 3, 4, 5, 6, 7)) |
| 21 | +} |
| 22 | + |
| 23 | +#[inline] |
| 24 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))] |
| 25 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprolvq))] |
| 26 | +unsafe fn rotate_left_variable(x: u64x8) -> u64x8 { |
| 27 | + x.rotate_left(u64x8::new(0, 1, 2, 3, 4, 5, 6, 7)) |
| 28 | +} |
| 29 | + |
| 30 | +#[inline] |
| 31 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))] |
| 32 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprorq))] |
| 33 | +unsafe fn rotate_right(x: u64x8) -> u64x8 { |
| 34 | + x.rotate_right(u64x8::splat(12)) |
| 35 | +} |
| 36 | + |
| 37 | +#[inline] |
| 38 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))] |
| 39 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprolq))] |
| 40 | +unsafe fn rotate_left(x: u64x8) -> u64x8 { |
| 41 | + x.rotate_left(u64x8::splat(12)) |
| 42 | +} |
| 43 | + |
| 44 | +#[inline] |
| 45 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))] |
| 46 | +#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprolq))] |
| 47 | +unsafe fn rotate_left_x2(x: u64x2) -> u64x2 { |
| 48 | + x.rotate_left(u64x2::splat(12)) |
| 49 | +} |
0 commit comments