Instruction
VPERMD
Rearranges the doublewords of a vector across the whole register using an index vector.
VPERMD takes doublewords from anywhere in a vector: element i of the result is the element of the table operand that element i of the index operand numbers. AVX2 added it, with VPERMPS for singles, as a way to move doublewords freely across the two 128-bit halves of a YMM register, which VPSHUFD and VPSHUFB cannot do. Only the low three bits of each index count (four in the 512-bit form), so an index wraps around; unlike PSHUFB’s selectors, none writes zero. There is no 128-bit form; within one XMM register, VPERMILPS with an index vector or VPSHUFB does the job.
The order of the operands is a trap. In Intel’s syntax
VPERMD ymm1, ymm2, ymm3/m256 takes the indices from ymm2 and the table
from ymm3 or memory. The AVX2 intrinsic
_mm256_permutevar8x32_epi32(table, indices) names them the other way
round, while the AVX-512 intrinsics such as
_mm512_permutexvar_epi32(indices, table) follow the instruction.
Typical uses:
- Fixed lane-crossing rearrangements with a constant index vector: reversing eight elements, rotating them, or interleaving the halves of a register.
- Left-packing. To keep only the elements that passed a comparison, code turns the comparison into an 8-bit mask, loads an index vector for that mask from a table of 256, and lets VPERMD move the chosen elements to the front. AVX-512 does this in one step with VPCOMPRESSD.
- Two tables. VPERMI2D and VPERMT2D of AVX-512 choose from the doublewords of two registers; Intel’s optimization manual notes that the first overwrites the index register and the second the first table.
The EVEX forms add masking and registers 16 to 31. GCC 14 at -O2 emits VPERMD for both intrinsics, while Clang 23 chooses between VPERMD and VPERMPS by the instructions around it, so integer code compiled with Clang may show VPERMPS.
In the optimization guide
What the optimization guide says about VPERMD, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Vectors
- Shuffles and lane crossing: Lane-crossing permutes such as VPERMD take longer than in-lane shuffles such as VPSHUFB, and LLVM treats them as slow on Zen. sources differ
Crestmont and Gracemont
- Vectors and AVX2: Shuffles that move data across the 128-bit halves are slower: VPERM2I128, VPERM2F128, VPERMD, VPERMQ, VPERMPS and VPERMPD on 256 bits are two micro-ops with a latency of 7 cycles, the second holding a port for two cycles.
Golden Cove and Raptor Cove
- Vectors, AVX-512 and AMX: VPERMD, VPERMQ, VPERMPS, VPERMPD, VPMULLQ,
vrange,vgetmantand the half-precision complex multiplications wait for the old value of their destination, which they then overwrite.
Ice Lake to Rocket Lake
- Vectors and AVX-512: Ice Lake adds an in-lane shuffle unit on port 1, while lane-crossing shuffles such as VPERMD stay on port 5.
Skylake to Cooper Lake
- Vectors on all parts: Shuffles and permutes run on port 5 only, one a cycle; those that move data between 128-bit lanes, such as VPERMD, take three cycles.
Zen 2
- Vectors and floating point: AMD’s spreadsheet makes the AVX2 permutes that cross the 128-bit lanes, VPERMD,
vpermps,vpermqandvpermpd, microcoded, whilevperm2f128is one macro-op of three cycles on pipe 2. sources differ
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VPERMD ymm, ymm, m256
VPERMD_YMMqq_YMMqq_MEMqq | VEX.256.66.0F38.W0 36 /r | AVX2 |
VPERMD ymm, ymm, ymm
VPERMD_YMMqq_YMMqq_YMMqq | VEX.256.66.0F38.W0 36 /r | AVX2 |
VPERMD zmm {k}{z}, zmm, zmm
VPERMD_ZMMu32_MASKmskw_ZMMu32_ZMMu32_AVX512 | EVEX.512.66.0F38.W0 36 /r | AVX10.1 or AVX512F |
VPERMD zmm {k}{z}, zmm, m512/m32bcst
VPERMD_ZMMu32_MASKmskw_ZMMu32_MEMu32_AVX512 | EVEX.512.66.0F38.W0 36 /r | AVX10.1 or AVX512F |
VPERMD ymm {k}{z}, ymm, ymm
VPERMD_YMMu32_MASKmskw_YMMu32_YMMu32_AVX512 | EVEX.256.66.0F38.W0 36 /r | AVX10.1 or AVX512F + AVX512VL |
VPERMD ymm {k}{z}, ymm, m256/m32bcst
VPERMD_YMMu32_MASKmskw_YMMu32_MEMu32_AVX512 | EVEX.256.66.0F38.W0 36 /r | AVX10.1 or AVX512F + AVX512VL |
Latency and throughput
| Model | ymm, ymm, m256 | ymm, ymm, ymm | zmm {k}{z}, zmm, zmm | zmm {k}{z}, zmm, m512/m32bcstymm {k}{z}, ymm, m256/m32bcst | ymm {k}{z}, ymm, ymm |
|---|---|---|---|---|---|
| Haswell, Skylake | 10 / 1p5 | 3 / 1p5 | |||
| Broadwell | 9 / 1p5 | 3 / 1p5 | |||
| Skylake-SP, Ice Lake | 10 / 1p5 | 3 / 1p5 | 3 / 1p5 | 10 / 1p5 | 3 / 1p5 |
| Alder Lake | 11 / 1p5 | 3 / 1p5 | |||
| Sapphire Rapids | 11 / 1p5 | 3 / 1p5 | 3 / 1p5 | 11 / 1p5 | 3 / 1p5 |
| Lunar Lake | 10 / 2.33V2 V3 | 3 / 0.5V2 V3 | |||
| Zen | 9 / 1FPU1 FPU2 | 2 / 1FPU1 FPU2 | |||
| Zen 2 | 9 / 0.5FPU1 FPU2 | 2 / 0.5FPU1 FPU2 | |||
| Zen 3 | 12 / 2FP1 | 5 / 1FP1 | |||
| Zen 4 | 11 / 1FP1 | 4 / 1FP1 | 5 / 1FP1 FP2 | 8 / 0.5FP1 FP2 | 4 / 11FP1 FP2 |
Data flow
Where the elements of the sources go, element 0 on the right; results that depend on a control value are drawn for an example. How to read.
Example index vector in zmm2 (element 0 on the right); only its low 4 bits count. Shown for the zmm form; the ymm form works the same on 8 doublewords. The EVEX forms write under a mask: where its bit is 0, the element keeps its old value, or zeroes it with {z}.
With the example indices, result doublewords 15 to 0: b8, unchanged (bit 14 of k1 is 0), b7, b10, b1, b5, b12, b5, b15, b2, b9, b6, b14, b0, b11, b3.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
n = VL // 32 # 8 in ymm, 16 in zmm
for i in range(n):
if k1[i]: # 1 without a write mask
zmm1.d[i] = src3.d[zmm2.d[i] % n]
elif zeroing:
zmm1.d[i] = 0
# else: zmm1.d[i] keeps its value
# m32bcst: src3.d[i] is the m32 for every i
# zmm1 is zeroed from bit VL upRun on AMD Zen 5 (EPYC 9645): 42 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VPERMD ymm, ymm, ymm/m256 | ||
ymm | explicit | write |
ymm | explicit | read |
ymm/m256 | explicit | read |
VPERMD ymm {k}{z}, ymm, ymm/m256/m32bcst VPERMD zmm {k}{z}, zmm, zmm/m512/m32bcst | ||
ymm, zmm | explicit | write (masked) |
{k} | explicit | read (write mask) |
ymm, zmm | explicit | read |
ymm/m256/m32bcst, zmm/m512/m32bcst | explicit | read |
Flags
None: XED records no flag that the forms test or change.
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- VEX forms
avx-type-4- EVEX forms
AVX512-E4NF
Attributes
What else XED records about the forms. How to read.
- EVEX forms
- write masking
- EVEX memory forms
- embedded broadcast (tuple Full)
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VPERMD, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.
| Intrinsic | Compiles to |
|---|---|
_mm256_permutevar8x32_epi32
__m256i _mm256_permutevar8x32_epi32(__m256i __a, __m256i __b) |
|
_mm256_permutexvar_epi32
__m256i _mm256_permutexvar_epi32(__m256i A, __m256i B) |
|
_mm256_mask_permutexvar_epi32
__m256i _mm256_mask_permutexvar_epi32(__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) |
|
_mm256_maskz_permutexvar_epi32
__m256i _mm256_maskz_permutexvar_epi32(__mmask8 __M, __m256i __X, __m256i __Y) |
|
_mm512_permutexvar_epi32
__m512i _mm512_permutexvar_epi32(__m512i __X, __m512i __Y) |
|
_mm512_mask_permutexvar_epi32
__m512i _mm512_mask_permutexvar_epi32(__m512i __W, __mmask16 __M, __m512i __X, __m512i __Y) |
|
_mm512_maskz_permutexvar_epi32
__m512i _mm512_maskz_permutexvar_epi32(__mmask16 __M, __m512i __X, __m512i __Y) |
|
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
More AVX2 instructions
- VPAND
- VPANDN
- VPAVGB
- VPAVGW
- VPBLENDD
- VPBLENDVB
- VPBLENDW
- VPBROADCASTB
- VPBROADCASTD
- VPBROADCASTQ
- VPBROADCASTW
- VPCMPEQB
- VPCMPEQD
- VPCMPEQQ
- VPCMPEQW
- VPCMPGTB
- VPCMPGTD
- VPCMPGTQ
- VPCMPGTW
- VPERM2I128
- VPERMPD
- VPERMPS
- VPERMQ
- VPGATHERDD
- VPGATHERDQ
- VPGATHERQD
- VPGATHERQQ
- VPHADDD
- VPHADDSW
- VPHADDW
- VPHSUBD
- VPHSUBSW
- VPHSUBW
- VPMADDUBSW
- VPMADDWD
- VPMASKMOVD
- VPMASKMOVQ
- VPMAXSB
- VPMAXSD
- VPMAXSW
More AVX10.1 instructions
- VPCMPGTD
- VPCMPGTQ
- VPCMPGTW
- VPCMPQ
- VPCMPUB
- VPCMPUD
- VPCMPUQ
- VPCMPUW
- VPCMPW
- VPCOMPRESSB
- VPCOMPRESSD
- VPCOMPRESSQ
- VPCOMPRESSW
- VPCONFLICTD
- VPCONFLICTQ
- VPDPBUSD
- VPDPBUSDS
- VPDPWSSD
- VPDPWSSDS
- VPERMB
- VPERMI2B
- VPERMI2D
- VPERMI2PD
- VPERMI2PS
- VPERMI2Q
- VPERMI2W
- VPERMILPD
- VPERMILPS
- VPERMPD
- VPERMPS
- VPERMQ
- VPERMT2B
- VPERMT2D
- VPERMT2PD
- VPERMT2PS
- VPERMT2Q
- VPERMT2W
- VPERMW
- VPEXPANDB
- VPEXPANDD
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Clang's x86 intrinsic headers, LLVM 23.1.2 (commit
85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2C, page 5-500 (VPERMD/
VPERMW) - Intel Advanced Vector Extensions 10.2 Architecture Specification, revision 7.0 (361050-007, April 2026)
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The intrinsics and their signatures come from Clang and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.