Se recomienda usar Visual Studio 2017
Esta documentación está archivada y no tiene mantenimiento.


Microsoft Specific

Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction palignr to extract a 128-bit byte aligned value.

__m128i _mm_alignr_epi8( 
   __m128i a,
   __m128i b,
   const int ralign 

[in] a

A 128-bit parameter that contains sixteen 8-bit integers.

[in] b

A 128-bit parameter that contains sixteen 8-bit integers.

[in] ralign

A constant that specifies how many bytes the interim result will be shifted to the right.

r := (CONCAT(a, b) >> (ralign * 8)) & 0xffffffffffffffff




x86, x64

Header file <tmmintrin.h>

r is the 128-bit result value.

CONCAT(a, b) is the 256-bit unsigned intermediate value that is a concatenation of parameters a and b. The result is this intermediate value shifted right by ralign bytes.

If ralign > 32, the result value is zero.

Before using this intrinsic, software must ensure that the processor supports the instruction.

// _mm_alignr_epi8
#include <stdio.h>
#include <tmmintrin.h>

int main () {
    __m128i a, b;

    a.m128i_u32[3] = 0x01234567;
    a.m128i_u32[2] = 0x89ABDCEF;
    a.m128i_u32[1] = 0x01234567;
    a.m128i_u32[0] = 0x89ABCDEF;
    b.m128i_u32[3] = 0xFFFFEEEE;
    b.m128i_u32[2] = 0xDDDDCCCC;
    b.m128i_u32[1] = 0xBBBBAAAA;
    b.m128i_u32[0] = 0x99998888;

    // A right align value of four should remove the lowest 4 bytes of "b"
    __m128i res = _mm_alignr_epi8( a, b, 4 );

    printf_s("Original a: 0x%016I64x%016I64x\nOriginal b: 0x%016I64x%016I64x\n",
        a.m128i_u64[1], a.m128i_u64[0],
        b.m128i_u64[1], b.m128i_u64[0]);

    printf_s("Result res: 0x%016I64x%016I64x\n",
        res.m128i_u64[1], res.m128i_u64[0]);

    return 0;
Original a: 0x0123456789abdcef0123456789abcdef
Original b: 0xffffeeeeddddccccbbbbaaaa99998888
Result res: 0x89abcdefffffeeeeddddccccbbbbaaaa