모두의 코드
PALIGNR (Intel x86/64 assembly instruction)

작성일 : 2020-09-01 이 글은 736 번 읽혔습니다.

PALIGNR

Packed Align Right

참고 사항

아래 표를 해석하는 방법은 x86-64 명령어 레퍼런스 읽는 법 글을 참조하시기 바랍니다.

Opcode/
Instruction

Op/
En

64/32 bit
Mode
Support

CPUID
Feature
Flag

Description

0F 3A 0F /r ib\footnote{1}
PALIGNR mm1 mm2/m64 imm8

RMI

V/V

SSSE3

Concatenate destination and source operands, extract byte-aligned result shifted to the right by constant value in imm8 into mm1.

66 0F 3A 0F /r ib
PALIGNR xmm1 xmm2/m128 imm8

RMI

V/V

SSSE3

Concatenate destination and source operands, extract byte-aligned result shifted to the right by constant value in imm8 into xmm1.

VEX.NDS.128.66.0F3A.WIG 0F /r ib
VPALIGNR xmm1 xmm2 xmm3/m128 imm8

RVMI

V/V

AVX

Concatenate xmm2 and xmm3/m128, extract byte aligned result shifted to the right by constant value in imm8 and result is stored in xmm1.

VEX.NDS.256.66.0F3A.WIG 0F /r ib
VPALIGNR ymm1 ymm2 ymm3/m256 imm8

RVMI

V/V

AVX2

Concatenate pairs of 16 bytes in ymm2 and ymm3/m256 into 32-byte intermediate result, extract byte-aligned, 16-byte result shifted to the right by constant values in imm8 from each intermediate result, and two 16-byte results are stored in ymm1.

EVEX.NDS.128.66.0F3A.WIG 0F /r ib
VPALIGNR xmm1 {k1}{z} xmm2 xmm3/m128 imm8

FVM

V/V

AVX512VL
AVX512BW

Concatenate xmm2 and xmm3/m128 into a 32-byte intermediate result, extract byte aligned result shifted to the right by constant value in imm8 and result is stored in xmm1.

EVEX.NDS.256.66.0F3A.WIG 0F /r ib
VPALIGNR ymm1 {k1}{z} ymm2 ymm3/m256 imm8

FVM

V/V

AVX512VL
AVX512BW

Concatenate pairs of 16 bytes in ymm2 and ymm3/m256 into 32-byte intermediate result, extract byte-aligned, 16-byte result shifted to the right by constant values in imm8 from each intermediate result, and two 16-byte results are stored in ymm1.

EVEX.NDS.512.66.0F3A.WIG 0F /r ib
VPALIGNR zmm1 {k1}{z} zmm2 zmm3/m512 imm8

FVM

V/V

AVX512BW

Concatenate pairs of 16 bytes in zmm2 and zmm3/m512 into 32-byte intermediate result, extract byte-aligned, 16-byte result shifted to the right by constant values in imm8 from each intermediate result, and four 16-byte results are stored in zmm1.

  1. See note in Section 2.4, "AVX and SSE Instruction Exception Specification" in the Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 2A and Section 22.25.3, "Exception Conditions of Legacy SIMD Instructions Operating on MMX Registers" in the Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3A

Instruction Operand Encoding

Op/En

Operand 1

Operand 2

Operand 3

Operand 4

RMI

ModRM:reg (r, w)

ModRM:r/m (r)

imm8

NA

RVMI

ModRM:reg (w)

VEX.vvvv (r)

ModRM:r/m (r)

imm8

FVM

ModRM:reg (w)

EVEX.vvvv (r)

ModRM:r/m (r)

NA

Description

(V)PALIGNR concatenates the destination operand (the first operand) and the source operand (the second operand) into an intermediate composite, shifts the composite at byte granularity to the right by a constant imme-diate, and extracts the right-aligned result into the destination. The first and the second operands can be an MMX,

XMM or a YMM register. The immediate value is considered unsigned. Immediate shift counts larger than the 2L (i.e. 32 for 128-bit operands, or 16 for 64-bit operands) produce a zero result. Both operands can be MMX regis-ters, XMM registers or YMM registers. When the source operand is a 128-bit memory operand, the operand must be aligned on a 16-byte boundary or a general-protection exception (#GP) will be generated.

In 64-bit mode and not encoded by VEX/EVEX prefix, use the REX prefix to access additional registers.

128-bit Legacy SSE version: Bits (VLMAX-1:128) of the corresponding YMM destination register remain unchanged.

EVEX.512 encoded version: The first source operand is a ZMM register and contains four 16-byte blocks. The second source operand is a ZMM register or a 512-bit memory location containing four 16-byte block. The destina-tion operand is a ZMM register and contain four 16-byte results. The imm8[7:0] is the common shift count

used for each of the four successive 16-byte block sources. The low 16-byte block of the two source operands produce the low 16-byte result of the destination operand, the high 16-byte block of the two source operands produce the high 16-byte result of the destination operand and so on for the blocks in the middle.

VEX.256 and EVEX.256 encoded versions: The first source operand is a YMM register and contains two 16-byte blocks. The second source operand is a YMM register or a 256-bit memory location containing two 16-byte block. The destination operand is a YMM register and contain two 16-byte results. The imm8[7:0] is the common shift count used for the two lower 16-byte block sources and the two upper 16-byte block sources. The low 16-byte block of the two source operands produce the low 16-byte result of the destination operand, the high 16-byte block of the two source operands produce the high 16-byte result of the destination operand. The upper bits (MAX_VL-1:256) of the corresponding ZMM register destination are zeroed.

VEX.128 and EVEX.128 encoded versions: The first source operand is an XMM register. The second source operand is an XMM register or 128-bit memory location. The destination operand is an XMM register. The upper bits (MAX_VL-1:128) of the corresponding ZMM register destination are zeroed.

Concatenation is done with 128-bit data in the first and second source operand for both 128-bit and 256-bit instructions. The high 128-bits of the intermediate composite 256-bit result came from the 128-bit data from the first source operand; the low 128-bits of the intermediate result came from the 128-bit data of the second source operand.

Note: VEX.L must be 0, otherwise the instruction will #UD.

T S 7 1 T E D 8 5 5 2 2 C 2 1 2 C R S 5 2 S 7 1 * ] 0 : [ 8 m I * 0 [ m I 1 C S 2 : 5 0 0 8 8 2 5 2 E D 1 7 ] 1 7 R C 2 R 8 8 1 1 R 8 S 5 m 2 m S 2 7 0
Figure 4-7. 256-bit VPALIGN Instruction Operation

Operation

PALIGNR (with 64-bit operands)

    temp1[127:0] = CONCATENATE(DEST,SRC)>>(imm8*8) 
    DEST[63:0] = temp1[63:0] 

PALIGNR (with 128-bit operands)

temp1[255:0] <-  ((DEST[127:0] << 128) OR SRC[127:0])>>(imm8*8);
DEST[127:0] <-  temp1[127:0]
DEST[VLMAX-1:128] (Unmodified)

VPALIGNR (VEX.128 encoded version)

temp1[255:0] <-  ((SRC1[127:0] << 128) OR SRC2[127:0])>>(imm8*8);
DEST[127:0] <-  temp1[127:0]
DEST[VLMAX-1:128] <-  0

VPALIGNR (VEX.256 encoded version)

temp1[255:0] <-  ((SRC1[127:0] << 128) OR SRC2[127:0])>>(imm8[7:0]*8);
DEST[127:0] <-  temp1[127:0]
temp1[255:0] <-  ((SRC1[255:128] << 128) OR SRC2[255:128])>>(imm8[7:0]*8);
DEST[MAX_VL-1:128] <-  temp1[127:0]

VPALIGNR (EVEX encoded versions)

(KL, VL) = (16, 128), (32, 256), (64, 512)
FOR l <-  0 TO VL-1 with increments of 128
    temp1[255:0] <- ((SRC1[l+127:l] << 128) OR SRC2[l+127:l])>>(imm8[7:0]*8);
    TMP_DEST[l+127:l] <- temp1[127:0]
ENDFOR;
FOR j <-  0 TO KL-1
    i <-  j * 8
    IF k1[j] OR *no writemask*
          THEN DEST[i+7:i] <-  TMP_DEST[i+7:i]
          ELSE 
                IF *merging-masking* ; merging-masking
                      THEN *DEST[i+7:i] remains unchanged*
                      ELSE *zeroing-masking* ; zeroing-masking
                            DEST[i+7:i] = 0
                FI
    FI;
ENDFOR;
DEST[MAX_VL-1:VL] <-  0

Intel C/C++ Compiler Intrinsic Equivalents

PALIGNR : __m64 _mm_alignr_pi8(__m64 a, __m64 b, int n)(V) PALIGNR
    : __m128i _mm_alignr_epi8(__m128i a, __m128i b, int n) VPALIGNR
    : __m256i
      _mm256_alignr_epi8(__m256i a, __m256i b, const int n) VPALIGNR __m512i
      _mm512_alignr_epi8(__m512i a, __m512i b, const int n) VPALIGNR __m512i
      _mm512_mask_alignr_epi8(__m512i s, __mmask64 m, __m512i a, __m512i b,
                              const int n) VPALIGNR __m512i
      _mm512_maskz_alignr_epi8(__mmask64 m, __m512i a, __m512i b,
                               const int n) VPALIGNR __m256i
      _mm256_mask_alignr_epi8(__m256i s, __mmask32 m, __m256i a, __m256i b,
                              const int n) VPALIGNR __m256i
      _mm256_maskz_alignr_epi8(__mmask32 m, __m256i a, __m256i b,
                               const int n) VPALIGNR __m128i
      _mm_mask_alignr_epi8(__m128i s, __mmask16 m, __m128i a, __m128i b,
                           const int n) VPALIGNR __m128i
      _mm_maskz_alignr_epi8(__mmask16 m, __m128i a, __m128i b, const int n)

SIMD Floating-Point Exceptions

None.

Other Exceptions

Non-EVEX-encoded instruction, see Exceptions Type 4.

EVEX-encoded instruction, see Exceptions Type E4NF.nb.

첫 댓글을 달아주세요!
프로필 사진 없음
강좌에 관련 없이 궁금한 내용은 여기를 사용해주세요

    댓글을 불러오는 중입니다..