Extensions
Forms
8 (4 VEX, 4 EVEX)
Data
Intel XED v2026.08.23

PDEP scatters the low bits of its source to the positions of the 1 bits of a mask, in order: bit 0 of the source goes to the lowest 1 of the mask, bit 1 to the next one, and so on. Every position where the mask has a 0 is cleared, and source bits beyond the mask’s number of ones are dropped. Depositing 0b101 into the mask 0xF0 gives 0x50. PEXT does the reverse, gathering the bits at the mask’s positions into the low bits, so PEXT of PDEP(x, m) with the same mask m gives back the low bits of x, as many as m has ones.

Operand order

In Intel syntax the source comes second and the mask third: pdep rax, rbx, rcx deposits RBX into the places of RCX, and only the mask may be in memory. The intrinsics _pdep_u32(src, mask) and _pdep_u64(src, mask) take them in the same order. There are 32- and 64-bit forms, no 16-bit one, and no flag changes.

Uses

  • The index of the n-th set bit of x, counting from 0: deposit the single bit 1 << n into the mask x and count the trailing zeros. GCC 14 and Clang 23 at -O2 compile _tzcnt_u64(_pdep_u64(1ULL << n, x)) to SHLX, PDEP and TZCNT; if x has n or fewer set bits, the result is 64.
  • Interleaving: _pdep_u64(x, 0x5555555555555555) spreads x over the even bits and _pdep_u64(y, 0xAAAAAAAAAAAAAAAA) y over the odd ones; their OR is the Morton code of the point (x, y).
  • Widening a bit mask: PDEP of an 8-bit mask into 0x0101010101010101 puts each bit at the bottom of its own byte, and a multiplication by 0xFF turns each byte into 0x00 or 0xFF.

Neither compiler finds PDEP in plain C.

Speed differs between processors

Intel’s optimization manual lists PDEP with MUL and IMUL among the instructions of the one “slow integer” unit of Golden Cove (Table 2-4). AMD’s Zen 5 guide says that Zen 5 runs PDEP and PEXT natively in three of its ALUs, three per cycle with a latency of three cycles, and tells software that chooses between code for fast and slow PDEP to take the fast code there (Section 2.10.2).

PDEP belongs to BMI2, part of x86-64-v3; APX adds an EVEX form that reaches its new registers.

In the optimization guide

What the optimization guide says about PDEP, a line per claim. Each links to the claim in the guide, with its sources and where they differ.

Golden Cove and Raptor Cove

  • Integer execution: Port 1 alone runs the slower integer operations: multiplication, PDEP and PEXT, popcnt, bsr, crc32 and the double shifts with an immediate count, which LLVM’s models give a latency of three cycles and one per cycle.

Skylake to Cooper Lake

  • Integer execution: Port 1 alone runs integer multiplication, PDEP and PEXT, popcnt, lzcnt, tzcnt, bsf, bsr and the double shifts, with a latency of three cycles and one a cycle in LLVM’s models, as on Golden Cove.

Zen and Zen+

  • Integer execution: PDEP and PEXT are microcoded, in AMD’s spreadsheet and in LLVM’s model, though the core supports BMI2; code with a choice uses shifts and masks instead.

Zen 2

  • Integer execution: PDEP and PEXT are microcoded, as in LLVM’s model, though CPUID reports BMI2; Zen 3 runs them on an ALU in three cycles.

Zen 3

  • Integer execution: PDEP and PEXT run natively on ALU 1, one per cycle with a latency of three cycles; code with a separate path for processors where they are slow, such as Zen 2, should take the fast path.

Zen 4

  • Integer execution: PDEP and PEXT run natively on one ALU, one per cycle with a latency of three cycles, against three per cycle on Zen 5; code with a separate path for processors where they are slow should take the fast path.

Zen 5

  • Integer execution: PDEP and PEXT run natively, three per cycle with a latency of three cycles; code with a separate path for processors where they are slow should take the fast path.

Forms

Every encoding of PDEP that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
PDEP r32, r32, m32 PDEP_GPR32d_GPR32d_MEMdVEX.LZ.F2.0F38.W0 F5 /rBMI2
PDEP r32, r32, r32 PDEP_GPR32d_GPR32d_GPR32dVEX.LZ.F2.0F38.W0 F5 /rBMI2
PDEP r64, r64, m64 64-bit mode only PDEP_GPR64q_GPR64q_MEMqVEX.LZ.F2.0F38.W1 F5 /rBMI2
PDEP r64, r64, r64 64-bit mode only PDEP_GPR64q_GPR64q_GPR64qVEX.LZ.F2.0F38.W1 F5 /rBMI2
PDEP r32, r32, r32 PDEP_GPR32i32_GPR32i32_GPR32i32_APXEVEX.LLZ.F2.0F38.W0 F5 /rAPX_F + BMI2
PDEP r32, r32, m32 PDEP_GPR32i32_GPR32i32_MEMi32_APXEVEX.LLZ.F2.0F38.W0 F5 /rAPX_F + BMI2
PDEP r64, r64, r64 PDEP_GPR64i64_GPR64i64_GPR64i64_APXEVEX.LLZ.F2.0F38.W1 F5 /rAPX_F + BMI2
PDEP r64, r64, m64 PDEP_GPR64i64_GPR64i64_MEMi64_APXEVEX.LLZ.F2.0F38.W1 F5 /rAPX_F + BMI2

Latency and throughput

What the scheduling models of LLVM 23.1.2 give for each form, not measurements: latency / reciprocal throughput in cycles, the ports under them. A row is a model, or models that agree; a dash, a form that its processors lack. Memory forms: latency from the address, ports without the load and store units. Which processors each model covers.
Modelr32, r32, m32
r64, r64, m64
r32, r32, r32
r64, r64, r64
Haswell, Broadwell, Skylake, Skylake-SP, Ice Lake, Alder Lake, Sapphire Rapids8 / 1p13 / 1p1
Lunar Lake7 / 1.33p1353 / 1p135
Zen, Zen 2100 / 0.25100 / 0.25
Zen 3, Zen 45 / 0.33ALU0 ALU1 ALU2 ALU33 / 1ALU1

Operation

What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.

s = src.read()
m = mask.read()
r = 0
k = 0                            # the next bit of src, from bit 0 up
for i in range(OSIZE):
    if m >> i & 1:
        r |= (s >> k & 1) << i   # to the place of the next 1 bit of mask
        k += 1
dest.write(r)                    # a 32-bit register: bits 63:32 cleared

Run on AMD Zen 5 (EPYC 9645): 36 cases. The APX forms were not run: none of these processors has APX.

Operands

What each form reads and writes, as Intel XED records it: the operands of its syntax, in order, and the implicit ones that the syntax does not name. How to read.
OperandKindAction
PDEP r32, r32, r/m32 PDEP r64, r64, r/m64 64-bit mode only
r32/64explicitwrite
r32/64explicitread
r/m32/64explicitread

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
none in XED
EVEX forms
APX-EVEX-BMI

Intrinsics

The C intrinsics of Clang 23.1.2 that compile to PDEP, 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.

IntrinsicCompiles to
_pdep_u32 unsigned int _pdep_u32(unsigned int __X, unsigned int __Y)

PDEP r32, r32, r32 VEX.LZ -mbmi2

_pdep_u64 unsigned long long _pdep_u64(unsigned long long __X, unsigned long long __Y)

PDEP r64, r64, r64 VEX.LZ -mbmi2

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.

CPUID requirements and processors of the XED ISA sets above. Alternatives are separated by “or”; processors follow XED’s chip model, whose AMD processors end with Zen 2, and the CPU data of this site for Zen 3 to Zen 6.

More BMI2 instructions

More APX instructions

All 88 APX instructions

Sources

  1. Intel XED v2026.08.23 (commit 0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model.
  2. The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s -march feature sets and AMD’s Processor Programming References, which the page of each processor cites.
  3. 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.
  4. LLVM 23.1.2's x86 scheduling models (commit 85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them.
  5. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-282 (PDEP)
  6. Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 9.0 (355828-009, August 2026)
  7. AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
  8. Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
  9. Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP

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.