Skip to content

Commit

Permalink
rotate instr tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIronBorn committed Jun 27, 2018
1 parent 1271a3f commit d252959
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coresimd/ppsv/api/rotates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ macro_rules! impl_vector_rotates {
/// the end of the resulting integer.
///
/// Please note this isn't the same operation as `<<`!. Also note it
/// isn't equivalent to `slice::rotate_left` (that can be implemented
/// with vector shuffles).
/// isn't equivalent to `slice::rotate_left`, it doesn't move the vector's
/// lanes around. (that can be implemented with vector shuffles).
#[inline]
pub fn rotate_left(self, n: $id) -> $id {
const LANE_WIDTH: $elem_ty = ::mem::size_of::<$elem_ty>() as $elem_ty * 8;
Expand Down
49 changes: 49 additions & 0 deletions crates/coresimd/tests/rotate_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! rotate instruction tests
#![feature(stdsimd)]
#![feature(proc_macro)]
#![feature(avx512_target_feature)]
#![feature(abi_vectorcall)]

extern crate stdsimd_test;
extern crate stdsimd;

use stdsimd::simd::*;
use stdsimd_test::assert_instr;

// Verify that supported hardware compiles rotates into single instructions

#[inline]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprorvq))]
unsafe fn rotate_right_variable(x: u64x8) -> u64x8 {
x.rotate_right(u64x8::new(0, 1, 2, 3, 4, 5, 6, 7))
}

#[inline]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprolvq))]
unsafe fn rotate_left_variable(x: u64x8) -> u64x8 {
x.rotate_left(u64x8::new(0, 1, 2, 3, 4, 5, 6, 7))
}

#[inline]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprorq))]
unsafe fn rotate_right(x: u64x8) -> u64x8 {
x.rotate_right(u64x2::splat(12))
}

#[inline]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprolq))]
unsafe fn rotate_left(x: u64x8) -> u64x8 {
x.rotate_left(u64x2::splat(12))
}

#[inline]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), target_feature(enable = "avx512f"))]
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), assert_instr(vprolq))]
unsafe fn rotate_left_x2(x: u64x2) -> u64x2 {
x.rotate_left(u64x2::splat(12))
}

0 comments on commit d252959

Please sign in to comment.