_mm_roti_epi64
Visual Studio 2010 SP1 is required.
Microsoft Specific
Generates the XOP instruction vprotq to rotate each of the quadwords in its first source by the amount specified in the second.
__m128i _mm_roti_epi64 (
__m128i src,
int count
);
Parameters
[in] src
A 128-bit parameter that contains two 64-bit unsigned integers.[in] count
An integer rotation count, preferably constant.
Return value
A 128-bit result r that contains two 64-bit unsigned integers.
r[i] := (count > 0) ? rotate_left(src[i], count) :
rotate_right(src[i], -count);
Requirements
Intrinsic |
Architecture |
---|---|
_mm_roti_epi64 |
XOP |
Header file <intrin.h>
Remarks
Each 64-bit unsigned integer value in src is rotated by the number of bits specified in count, and the 64-bit unsigned integer result is stored as the corresponding value in the destination. If the value in count is positive, the rotation is to the left (toward the most significant bit); otherwise, it is to the right.
The vprotq instruction has one form for constant arguments, another for non-constant arguments. If the value of count cannot be determined to be constant at compile time, the compiler will generate extra code to set up and use the non-constant version of vprotq. The constant version of vprotq is faster.
The vprotq instruction is part of the XOP family of instructions. Before you use this intrinsic, you must ensure that the processor supports this instruction. To determine hardware support for this instruction, call the __cpuid intrinsic with InfoType = 0x80000001 and check bit 11 of CPUInfo[2] (ECX). This bit is 1 when the instruction is supported, and 0 otherwise.
Example
#include <stdio.h>
#include <intrin.h>
int main()
{
__m128i a, d;
int i, j;
unsigned __int64 temp;
for (i = 0; i < 2; i++) {
temp = 0;
for (j = 0; j < 16; j++) {
temp = temp << 4 | (8*i + j + 7) % 16;
}
a.m128i_u64[i] = temp;
}
d = _mm_roti_epi64(a, 60);
printf_s("data: ");
for (i = 0; i < 2; i++) printf_s(" %016I64x", a.m128i_u64[i]);
printf_s("\nrotated by 60 gives");
for (i = 0; i < 2; i++) printf_s(" %016I64x", d.m128i_u64[i]);
printf_s("\n");
}
data: 789abcdef0123456 f0123456789abcde rotated by 60 gives 6789abcdef012345 ef0123456789abcd