Instruction
VPERMIL2PS
Picks each single from either of two sources, or zero, by selectors in a third source and an immediate; XOP.
An AMD extension: Intel processors do not have this instruction.
- Extensions
- Forms
- 6 (6 VEX)
- Data
- Intel XED v2026.08.23
VPERMIL2PS fills each doubleword of the destination with a doubleword
from one of two sources, or with zero, as a selector in a third source
says. It has five operands, dest, src1, src2, src3, m2z, in XMM or YMM
registers. Each doubleword of src3 steers the destination doubleword
at its own position:
| Selector bits | Use |
|---|---|
| 1:0 | which of the four doublewords in the lane |
| 2 | the source: 0 for src1, 1 for src2 |
| 3 | M, tested with M2Z |
| 31:4 | ignored |
Choices stay inside the 128-bit lane, as with VPERMILPS, whose one source it extends to two. VPERMIL2PD does the same for doubles. For elements in any lane, AVX-512 has VPERMI2PS.
The zero rule
M2Z is bits 1:0 of the immediate byte, and it decides what M means:
| M2Z | Element is zero when |
|---|---|
| 00b or 01b | never |
| 10b | M is 1 |
| 11b | M is 0 |
Bits 7:4 of the same byte name a register, src2 or src3, and bits
3:2 are ignored. VEX.W puts the operand that may be in memory second or
third: src2 with W0, the selector with W1.
XOP in a VEX prefix
The encoding is VEX C4 in map 3, opcode 48h, not the 8F that most XOP instructions start with. AMD’s manual still files it under XOP and tests the XOP bit.
In our builds
GCC 14 and Clang 23 at -O2 with -mxop compile _mm_permute2_ps(a, b, c, 3) and _mm256_permute2_ps to it. Clang also picks it alone:
__builtin_shufflevector(a, b, 0, 9, 3, 10, 4, 13, 6, 14) on eight
floats becomes one VPERMIL2PS with a selector from memory. GCC 14 builds
that shuffle from two VPERMILPS and a VUNPCKLPS.
AMD only
XOP came with AMD’s Bulldozer family and left with Zen (Zen 1 guide); CPUID.80000001H:ECX[11] reports it. Zen 5 clears that bit and raised #UD for all six recorded forms.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VPERMIL2PS xmm, xmm, m128, xmm, imm8
VPERMIL2PS_XMMdq_XMMdq_MEMdq_XMMdq_IMMb | VEX.128.66.0F3A.W0 48 /r /is4 | XOP |
VPERMIL2PS xmm, xmm, xmm, xmm, imm8
VPERMIL2PS_XMMdq_XMMdq_XMMdq_XMMdq_IMMb | VEX.128.66.0F3A.W0 48 /r /is4VEX.128.66.0F3A.W1 48 /r /is4 | XOP |
VPERMIL2PS ymm, ymm, m256, ymm, imm8
VPERMIL2PS_YMMqq_YMMqq_MEMqq_YMMqq_IMMb | VEX.256.66.0F3A.W0 48 /r /is4 | XOP |
VPERMIL2PS ymm, ymm, ymm, ymm, imm8
VPERMIL2PS_YMMqq_YMMqq_YMMqq_YMMqq_IMMb | VEX.256.66.0F3A.W0 48 /r /is4VEX.256.66.0F3A.W1 48 /r /is4 | XOP |
VPERMIL2PS xmm, xmm, xmm, m128, imm8
VPERMIL2PS_XMMdq_XMMdq_XMMdq_MEMdq_IMMb | VEX.128.66.0F3A.W1 48 /r /is4 | XOP |
VPERMIL2PS ymm, ymm, ymm, m256, imm8
VPERMIL2PS_YMMqq_YMMqq_YMMqq_MEMqq_IMMb | VEX.256.66.0F3A.W1 48 /r /is4 | XOP |
Latency and throughput
| Model | xmm, xmm, m128, xmm, imm8xmm, xmm, xmm, m128, imm8 | xmm, xmm, xmm, xmm, imm8 | ymm, ymm, m256, ymm, imm8ymm, ymm, ymm, m256, imm8 | ymm, ymm, ymm, ymm, imm8 |
|---|---|---|---|---|
| Piledriver | 8 / 1.5FPU1 FPXBR | 3 / 1FPU1 FPXBR | 8 / 2FPU1 FPXBR | 3 / 2FPU1 FPXBR |
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 selectors in ymm4 (element 0 on the right, in hex); only bits 3:0 count. Example: imm8 = 0x02, M2Z = 10b: the elements whose selector has bit 3 set are zeroed. No processor here has XOP: the example was not run, but worked out by the pseudocode below. Shown for the ymm form; the xmm form works the same on 4 singles.
With the example selectors and imm8 = 0x02, result singles 7 to 0: a4, b6, a5, b7, b0, 0, a2, b1.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
features = cpuid_leaf(0x80000001, 0)[2]
if not features >> 11 & 1:
fault(UD) # CPUID: no XOP
for i in range(VL // 32):
s = src4.d[i] # the selector of element i
j = i - i % 4 + (s & 3) # in the lane of element i
a = ymm2.d[j]
b = src3.d[j]
x = b if s & 4 else a
m = s >> 3 & 1 # M
if imm8 & 2 and m != imm8 & 1:
x = 0 # M2Z
ymm1.d[i] = x
# ymm1 is zeroed from bit VL upRun on AMD Zen 5 (EPYC 9645): 6 cases. Its cases ran where CPUID reported no XOP, and every one raised an exception.
Operands
| Operand | Kind | Action |
|---|---|---|
VPERMIL2PS xmm, xmm, xmm/m128, xmm, imm8 VPERMIL2PS ymm, ymm, ymm/m256, ymm, imm8 | ||
xmm, ymm | explicit | write |
xmm, ymm | explicit | read |
xmm/m128, ymm/m256 | explicit | read |
xmm, ymm | explicit | read |
imm8 | explicit | read |
VPERMIL2PS xmm, xmm, xmm, m128, imm8 VPERMIL2PS ymm, ymm, ymm, m256, imm8 | ||
xmm, ymm | explicit | write |
xmm, ymm | explicit | read |
xmm, ymm | explicit | read |
m128/256 | explicit | read |
imm8 | explicit | read |
Flags
None: XED records no flag that the forms test or change.
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VPERMIL2PS, 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 |
|---|---|
_mm_permute2_ps
__m128 _mm_permute2_ps(__m128 X, __m128 Y, __m128i C, const int I) |
|
_mm256_permute2_ps
__m256 _mm256_permute2_ps(__m256 X, __m256 Y, __m256i C, const int I) |
|
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.
| ISA set | CPUID | Processors |
|---|---|---|
XOP | XOP | Bulldozer, Piledriver |
More XOP instructions
- VFRCZPD
- VFRCZPS
- VFRCZSD
- VFRCZSS
- VPCMOV
- VPCOMB
- VPCOMD
- VPCOMQ
- VPCOMUB
- VPCOMUD
- VPCOMUQ
- VPCOMUW
- VPCOMW
- VPERMIL2PD
- VPHADDBD
- VPHADDBQ
- VPHADDBW
- VPHADDDQ
- VPHADDUBD
- VPHADDUBQ
- VPHADDUBW
- VPHADDUDQ
- VPHADDUWD
- VPHADDUWQ
- VPHADDWD
- VPHADDWQ
- VPHSUBBW
- VPHSUBDQ
- VPHSUBWD
- VPMACSDD
- VPMACSDQH
- VPMACSDQL
- VPMACSSDD
- VPMACSSDQH
- VPMACSSDQL
- VPMACSSWD
- VPMACSSWW
- VPMACSWD
- VPMACSWW
- VPMADCSSWD
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - 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. - AMD64 Architecture Programmer's Manual, Volume 4: 128-Bit, 256-Bit, and 512-Bit Media Instructions (26568, rev. 3.27, July 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.