Share via


_mm_rot_epi32

Visual Studio 2010 SP1 is required.

Microsoft Specific

Generates the XOP instruction vprotd to rotate each of the doublewords in its first source by an amount specified in the second.

__m128i _mm_rot_epi32 (
   __m128i src,
   __m128i counts
);

Parameters

  • [in] src
    A 128-bit parameter that contains four 32-bit unsigned integers.

  • [in] counts
    A 128-bit parameter that contains sixteen 8-bit signed integers.

Return value

A 128-bit result r that contains four 32-bit unsigned integers.

r[i] := (counts[4*i] > 0) ? rotate_left(src[i], counts[4*i]) : 
                            rotate_right(src[i], -counts[4*i]);

Requirements

Intrinsic

Architecture

_mm_rot_epi32

XOP

Header file <intrin.h>

Remarks

Each 32-bit unsigned integer value in src is rotated by the number of bits specified by the value in the byte of counts corresponding to its low-order byte, and the 32-bit unsigned integer result is stored as the corresponding value in the destination. If the value in counts is positive, the rotation is to the left (toward the most significant bit); otherwise, it is to the right. The other bytes of counts are ignored.

The vprotd 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, b, d;
    int i, j;
    unsigned int temp;
    for (i = 0; i < 4; i++) {
        temp = 0;
        for (j = 0; j < 8; j++) {
            temp = temp << 4 | (8*i + j + 7) % 16;
        }
        a.m128i_u32[i] = temp;
        b.m128i_i8[4*i] = 11*i - 21;
    }
    printf_s("data:       ");
    for (i = 0; i < 4; i++) printf_s(" %08x", a.m128i_u32[i]);
    printf_s("\nrotated by  ");
    for (i = 0; i < 4; i++) printf_s(" %8d", b.m128i_i8[4*i]);
    d = _mm_rot_epi32(a, b);
    printf_s("\ngives       ");
    for (i = 0; i < 4; i++) printf_s(" %08x", d.m128i_u32[i]);
    printf_s("\n");
}
data:        789abcde f0123456 789abcde f0123456
rotated by        -21      -10        1       12
gives        d5e6f3c4 15bc048d f13579bc 23456f01

See Also

Reference

_mm_rot_epi8

_mm_rot_epi16

_mm_rot_epi64

_mm_roti_epi32

_mm_shl_epi32

__cpuid, __cpuidex

XOP Intrinsics Added for Visual Studio 2010 SP1