Skip to content

Commit a71eb28

Browse files
author
TheIronBorn
committed
rotate instr tests
1 parent 1271a3f commit a71eb28

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

coresimd/ppsv/api/rotates.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ macro_rules! impl_vector_rotates {
99
/// the end of the resulting integer.
1010
///
1111
/// Please note this isn't the same operation as `<<`!. Also note it
12-
/// isn't equivalent to `slice::rotate_left` (that can be implemented
13-
/// with vector shuffles).
12+
/// isn't equivalent to `slice::rotate_left`, it doesn't move the vector's
13+
/// lanes around. (that can be implemented with vector shuffles).
1414
#[inline]
1515
pub fn rotate_left(self, n: $id) -> $id {
1616
const LANE_WIDTH: $elem_ty = ::mem::size_of::<$elem_ty>() as $elem_ty * 8;

crates/coresimd/tests/rotate_tests.rs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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

Comments
 (0)