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

ANDN computes NOT a AND b into a third register, leaving both sources as they were: andn eax, esi, edi gives ~ESI & EDI. The inverted operand is the first source, the register in VEX.vvvv; only the second source may be in memory. Without BMI1 the same takes a copy, a NOT and an AND. The vector PANDN and ANDNPS also invert their first operand.

How compilers use it

With -mbmi or -march=x86-64-v3, GCC 14 and Clang 23 at -O2 compile x & ~y to andn eax, esi, edi, with y, in ESI, as the inverted operand. Since ANDN sets ZF from its result, the test (x & ~y) == 0, which asks whether every bit of x is also set in y, becomes ANDN and SETE with no TEST between them.

Masks built at run time are another use: GCC 14 with -mbmi alone compiles (x >> s) & ((1ULL << n) - 1) to a shifted all-ones value and an ANDN that clears the field’s bits above n, where Clang 23 uses BEXTR; with BMI2 both use SHRX and BZHI instead.

What the flags say

ANDN clears OF and CF and sets SF and ZF from the result, as AND does, but leaves PF and AF undefined, where AND defines PF. Code that needs the parity of the result must compute it some other way. APX adds an EVEX form that reaches its new registers and one that leaves the flags unchanged (NF).

Speed

Intel’s optimization manual places ANDN among the instructions of the two bit-manipulation units of Golden Cove (Table 2-4). The instruction table of AMD’s Zen 5 guide lists ANDN as one macro-op with a latency of one cycle, on any of the integer ALUs.

ANDN belongs to BMI1, part of x86-64-v3.

Forms

Every encoding of ANDN that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
ANDN r32, r32, m32 ANDN_GPR32d_GPR32d_MEMdVEX.LZ.NP.0F38.W0 F2 /rBMI1
ANDN r32, r32, r32 ANDN_GPR32d_GPR32d_GPR32dVEX.LZ.NP.0F38.W0 F2 /rBMI1
ANDN r64, r64, m64 64-bit mode only ANDN_GPR64q_GPR64q_MEMqVEX.LZ.NP.0F38.W1 F2 /rBMI1
ANDN r64, r64, r64 64-bit mode only ANDN_GPR64q_GPR64q_GPR64qVEX.LZ.NP.0F38.W1 F2 /rBMI1
ANDN r32, r32, r32 ANDN_GPR32i32_GPR32i32_GPR32i32_APXEVEX.LLZ.NP.0F38.W0 F2 /rAPX_F + BMI1
ANDN r32, r32, m32 ANDN_GPR32i32_GPR32i32_MEMi32_APXEVEX.LLZ.NP.0F38.W0 F2 /rAPX_F + BMI1
ANDN r32, r32, r32 NF ANDN_GPR32i32_GPR32i32_GPR32i32_APX_N3EVEX.LLZ.NP.0F38.W0 F2 /r NF=1APX_F + APX_NCI_NDD_NF + BMI1
ANDN r32, r32, m32 NF ANDN_GPR32i32_GPR32i32_MEMi32_APX_N3EVEX.LLZ.NP.0F38.W0 F2 /r NF=1APX_F + APX_NCI_NDD_NF + BMI1
ANDN r64, r64, r64 ANDN_GPR64i64_GPR64i64_GPR64i64_APXEVEX.LLZ.NP.0F38.W1 F2 /rAPX_F + BMI1
ANDN r64, r64, m64 ANDN_GPR64i64_GPR64i64_MEMi64_APXEVEX.LLZ.NP.0F38.W1 F2 /rAPX_F + BMI1
ANDN r64, r64, r64 NF ANDN_GPR64i64_GPR64i64_GPR64i64_APX_N3EVEX.LLZ.NP.0F38.W1 F2 /r NF=1APX_F + APX_NCI_NDD_NF + BMI1
ANDN r64, r64, m64 NF ANDN_GPR64i64_GPR64i64_MEMi64_APX_N3EVEX.LLZ.NP.0F38.W1 F2 /r NF=1APX_F + APX_NCI_NDD_NF + BMI1

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 Lake6 / 0.5p151 / 0.5p15
Alder Lake, Sapphire Rapids7 / 0.33p1 p5 p112 / 0.33p1 p5 p11
Lunar Lake7 / 0.33p1352 / 0.33p135
Zen5 / 0.5ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU3
Zen 3, Zen 45 / 0.33ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU3
Jaguar4 / 1ALU0 ALU11 / 0.5ALU0 ALU1

Operation

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

r = ~src1 & src2                 # src2 with the bits of src1 cleared
if not nf:                       # NF=1 (APX) leaves the flags as they were
    sf = msb(r)
    zf = r == 0
    of = cf = 0
    af = pf = UNDEFINED
dest.write(r)                    # a 32-bit register: bits 63:32 cleared

Run on AMD Zen 5 (EPYC 9645): 56 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
ANDN r32, r32, r/m32 ANDN r64, r64, r/m64 64-bit mode only
r32/64explicitwrite
r32/64explicitread
r/m32/64explicitread
RFLAGSimplicitwrite
ANDN r32, r32, r/m32 NF ANDN r64, r64, r/m64 NF
r32/64explicitwrite
r32/64explicitread
r/m32/64explicitread

Flags

M modified, 0 cleared, U undefined; blank: not affected. How to read.
OFSFZFAFPFCF
NF forms
Not affected
Other forms
0MMUU0

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 ANDN, 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
__andn_u32 unsigned int __andn_u32(unsigned int __X, unsigned int __Y)

ANDN r32, r32, r32 VEX.LZ -mbmi

__andn_u64 unsigned long long __andn_u64(unsigned long long __X, unsigned long long __Y)

ANDN r64, r64, r64 VEX.LZ -mbmi

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.
ISA setCPUIDProcessors
BMI1

BMI1
CPUID.(EAX=07H,ECX=0):EBX[3] BMI1

Haswell, Broadwell, Skylake, Comet Lake, Cannon Lake, Ice Lake (client), Tiger Lake, Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Skylake-SP, Cascade Lake, Cooper Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Sierra Forest, Clearwater Forest, Knights Landing, Knights Mill, Zen 3, Zen 4, Zen 5, Zen 6

Note: XED's Piledriver adds TBM and FMA to Bulldozer but not BMI1, and its Zen chips inherit that gap; GCC's -march=bdver2 and later and -march=znver1 and later include BMI1.

APX_F_BMI1

APX_F + BMI1
CPUID.(EAX=07H,ECX=1):EDX[21] APX_F
CPUID.(EAX=07H,ECX=0):EBX[3] BMI1

Nova Lake, Diamond Rapids
APX_F_BMI1_N3

APX_F + APX_NCI_NDD_NF + BMI1
CPUID.(EAX=07H,ECX=1):EDX[21] APX_F
CPUID.(EAX=29H,ECX=0):EBX[0] APX_NCI_NDD_NF
CPUID.(EAX=07H,ECX=0):EBX[3] BMI1

Same as APX_F_BMI1

More BMI1 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 2A, page 3-62 (ANDN)
  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.