Instruction
XOR
Computes the bitwise exclusive OR of two operands; APX adds three-operand forms and forms that leave the flags unchanged.
- Extensions
- Forms
- 60 (24 Legacy, 36 EVEX)
- Data
- Intel XED v2026.08.23
XOR sets each bit of the result where its two operands differ. Beyond combining bit masks, compiled code uses it in three ways.
Zeroing a register
xor eax, eax sets a register to 0. GCC 14 and Clang 23 at -O2 compile
return 0; to it for int and long alike, since a 32-bit write
clears bits 63:32 as well. It takes 2 bytes, where xor rax, rax takes
3 and mov eax, 0 takes 5.
Processors treat it as more than an XOR: the result cannot depend on the register’s old value, so they do not wait for it. Intel’s Optimization Reference Manual lists XOR and SUB of a register with itself among the dependency-breaking zero idioms, which from Sandy Bridge on need neither an issue port nor an execution unit (Section 3.5.1.7); AMD’s guide for Zen 5 lists both as zeroing idioms that execute in 0 cycles (Section 2.9.2).
The catch is the flags, which XOR writes: where they must survive,
Intel’s manual recommends a MOV of 0 instead. The flags also decide
where the XOR goes. For return a < b; both compilers emit
xor eax, eax, cmp rdi, rsi and setl al: SETcc
writes only AL, so the rest of EAX must be cleared beforehand, and an
XOR placed after the CMP would destroy the flags that SETL reads.
Flipping bits
XOR with a constant flips the bits set in the constant (x ^ 32
becomes xor eax, 32). For a bit whose number is in a register both
compilers use BTC instead, so x ^ (1u << n) becomes
btc eax, esi. Flipping every bit, x ^ -1, compiles to
NOT, which is a byte shorter and leaves the flags alone.
Vector registers and memory
The idiom carries over to vector registers: Intel’s list includes
PXOR and XORPS of a register with itself
and their VEX and EVEX forms, and AMD’s includes VPXOR and VXORPS. With
LOCK and a memory destination, XOR flips bits atomically:
atomic_fetch_xor compiles to lock xor qword ptr [rdi], rsi when its
result is unused and to a CMPXCHG loop when it is
used.
In the optimization guide
What the optimization guide says about XOR, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Out of order
- Zeroing and dependency-breaking idioms:
xor eax, eaxandsub eax, eaxgive zero whatever EAX held, and every core here recognizes them as it renames: the result needs no execution unit and does not wait for the old value, so the idiom also ends any chain through the register. - Zeroing and dependency-breaking idioms: The idioms write the flags, as any
xororsubdoes.
Crestmont and Gracemont
- Integer execution: Moves, NOPs and zeroing idioms are handled at allocation and may never execute.
Ice Lake to Rocket Lake
- Integer execution: On Ice Lake, moves between general registers are no longer removed at renaming, and zeroing idioms take an execution unit. sources differ
Skylake to Cooper Lake
- Integer execution:
xor,suband the vectorpxor,xorps,pandn,psubandpcmpgtof a register with itself zero it without an execution unit, four a cycle, for 32-bit and 64-bit and all vector registers.
Zen and Zen+
- Integer execution: Register-to-register moves of 32-bit and 64-bit general registers and of XMM registers, and
xchgof general registers, take no execution cycle, while a YMM move renames only its lower half and moves the upper one in a pipe. sources differ
Zen 2
- Integer execution: Register-to-register moves of general registers of 32 and 64 bits,
xchgof them and moves of whole XMM and YMM registers take no execution cycle, where Zen 1 moves the upper half of a YMM register in a pipe. sources differ
Zen 3
- Integer execution: Register-to-register moves of general registers of 32 and 64 bits,
xchgof them and moves of whole XMM and YMM registers take no execution cycle, nor do the zeroing idioms such asxor eax, eaxandvpxor, which also break the dependency on the old value;sbb eax, eaxdepends only on the carry flag, andpcmpeqd xmm0, xmm0sets all ones without waiting. sources differ
Zen 4
- Integer execution: Register-to-register moves of general registers of 32 and 64 bits,
xchgof them and moves of whole vector registers take no execution cycle, nor do the zeroing idioms such asxor eax, eaxandvpxor, which also break the dependency on the old value;sbb eax, eaxdepends only on the carry flag. sources differ
Zen 5
- Integer execution: Register-to-register moves of 32-bit and 64-bit general registers and of whole vector registers take no execution cycle, nor do the zeroing idioms such as
xor eax, eaxandvpxor, which also break the dependency on the old value.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
XOR m8, imm8
XOR_MEMb_IMMb_80r6 | 80 /6 ib | Base instruction set |
XOR r8, imm8
XOR_GPR8_IMMb_80r6 | 80 /6 ib | Base instruction set |
XOR m16/32/64, imm16/32
XOR_MEMv_IMMz | 81 /6 iw/id | Base instruction set |
XOR r16/32/64, imm16/32
XOR_GPRv_IMMz | 81 /6 iw/id | Base instruction set |
XOR m8, imm8 not in 64-bit mode
XOR_MEMb_IMMb_82r6 | 82 /6 ib | Base instruction set |
XOR r8, imm8 not in 64-bit mode
XOR_GPR8_IMMb_82r6 | 82 /6 ib | Base instruction set |
XOR m16/32/64, imm8
XOR_MEMv_IMMb | 83 /6 ib | Base instruction set |
XOR r16/32/64, imm8
XOR_GPRv_IMMb | 83 /6 ib | Base instruction set |
XOR m8, r8
XOR_MEMb_GPR8 | 30 /r | Base instruction set |
XOR r8, r8
XOR_GPR8_GPR8_30 | 30 /r | Base instruction set |
XOR m16/32/64, r16/32/64
XOR_MEMv_GPRv | 31 /r | Base instruction set |
XOR r16/32/64, r16/32/64
XOR_GPRv_GPRv_31 | 31 /r | Base instruction set |
XOR r8, r8
XOR_GPR8_GPR8_32 | 32 /r | Base instruction set |
XOR r8, m8
XOR_GPR8_MEMb | 32 /r | Base instruction set |
XOR r16/32/64, r16/32/64
XOR_GPRv_GPRv_33 | 33 /r | Base instruction set |
XOR r16/32/64, m16/32/64
XOR_GPRv_MEMv | 33 /r | Base instruction set |
XOR AL, imm8
XOR_AL_IMMb | 34 ib | Base instruction set |
XOR rAX, imm16/32
XOR_OrAX_IMMz | 35 iw/id | Base instruction set |
LOCK XOR m8, imm8
XOR_LOCK_MEMb_IMMb_80r6 | 80 /6 ib | Base instruction set |
LOCK XOR m16/32/64, imm16/32
XOR_LOCK_MEMv_IMMz | 81 /6 iw/id | Base instruction set |
LOCK XOR m8, imm8 not in 64-bit mode
XOR_LOCK_MEMb_IMMb_82r6 | 82 /6 ib | Base instruction set |
LOCK XOR m16/32/64, imm8
XOR_LOCK_MEMv_IMMb | 83 /6 ib | Base instruction set |
LOCK XOR m8, r8
XOR_LOCK_MEMb_GPR8 | 30 /r | Base instruction set |
LOCK XOR m16/32/64, r16/32/64
XOR_LOCK_MEMv_GPRv | 31 /r | Base instruction set |
XOR r8, r8
XOR_GPR8i8_GPR8i8_APX | EVEX.LLZ.NP.MAP4.WIG 30 /rEVEX.LLZ.NP.MAP4.WIG 32 /r | APX_F |
XOR m8, r8
XOR_MEMi8_GPR8i8_APX | EVEX.LLZ.NP.MAP4.WIG 30 /r | APX_F |
XOR r8, r8 NF
XOR_GPR8i8_GPR8i8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 30 /r NF=1EVEX.LLZ.NP.MAP4.WIG 32 /r NF=1 | APX_F + APX_NCI_NDD_NF |
XOR m8, r8 NF
XOR_MEMi8_GPR8i8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 30 /r NF=1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, r16/32/64, imm8 NDD NF optional
XOR_GPRv_GPRv_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 83 /6 ib ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, m16/32/64, imm8 NDD NF optional
XOR_GPRv_MEMv_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 83 /6 ib ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r8, r8, r8 NDD NF optional
XOR_GPR8i8_GPR8i8_GPR8i8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 30 /r ND=1 NF=0/1EVEX.LLZ.NP.MAP4.WIG 32 /r ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r8, m8, r8 NDD NF optional
XOR_GPR8i8_MEMi8_GPR8i8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 30 /r ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, r16/32/64
XOR_GPRv_GPRv_APX | EVEX.LLZ.NP.MAP4.SCALABLE 31 /rEVEX.LLZ.NP.MAP4.SCALABLE 33 /r | APX_F |
XOR m16/32/64, r16/32/64
XOR_MEMv_GPRv_APX | EVEX.LLZ.NP.MAP4.SCALABLE 31 /r | APX_F |
XOR r16/32/64, r16/32/64 NF
XOR_GPRv_GPRv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 31 /r NF=1EVEX.LLZ.NP.MAP4.SCALABLE 33 /r NF=1 | APX_F + APX_NCI_NDD_NF |
XOR m16/32/64, r16/32/64 NF
XOR_MEMv_GPRv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 31 /r NF=1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, r16/32/64, r16/32/64 NDD NF optional
XOR_GPRv_GPRv_GPRv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 31 /r ND=1 NF=0/1EVEX.LLZ.NP.MAP4.SCALABLE 33 /r ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, m16/32/64, r16/32/64 NDD NF optional
XOR_GPRv_MEMv_GPRv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 31 /r ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r8, m8
XOR_GPR8i8_MEMi8_APX | EVEX.LLZ.NP.MAP4.WIG 32 /r | APX_F |
XOR r8, m8 NF
XOR_GPR8i8_MEMi8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 32 /r NF=1 | APX_F + APX_NCI_NDD_NF |
XOR r8, r8, m8 NDD NF optional
XOR_GPR8i8_GPR8i8_MEMi8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 32 /r ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, m16/32/64
XOR_GPRv_MEMv_APX | EVEX.LLZ.NP.MAP4.SCALABLE 33 /r | APX_F |
XOR r16/32/64, m16/32/64 NF
XOR_GPRv_MEMv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 33 /r NF=1 | APX_F + APX_NCI_NDD_NF |
XOR r8, r8, imm8 NDD NF optional
XOR_GPR8i8_GPR8i8_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 80 /6 ib ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r8, m8, imm8 NDD NF optional
XOR_GPR8i8_MEMi8_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 80 /6 ib ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, r16/32/64, m16/32/64 NDD NF optional
XOR_GPRv_GPRv_MEMv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 33 /r ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r8, imm8
XOR_GPR8i8_IMM8_APX | EVEX.LLZ.NP.MAP4.WIG 80 /6 ib | APX_F |
XOR m8, imm8
XOR_MEMi8_IMM8_APX | EVEX.LLZ.NP.MAP4.WIG 80 /6 ib | APX_F |
XOR r8, imm8 NF
XOR_GPR8i8_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 80 /6 ib NF=1 | APX_F + APX_NCI_NDD_NF |
XOR m8, imm8 NF
XOR_MEMi8_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 80 /6 ib NF=1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, imm16/32
XOR_GPRv_IMMz_APX | EVEX.LLZ.NP.MAP4.SCALABLE 81 /6 iw/id | APX_F |
XOR m16/32/64, imm16/32
XOR_MEMv_IMMz_APX | EVEX.LLZ.NP.MAP4.SCALABLE 81 /6 iw/id | APX_F |
XOR r16/32/64, imm16/32 NF
XOR_GPRv_IMMz_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 81 /6 iw/id NF=1 | APX_F + APX_NCI_NDD_NF |
XOR m16/32/64, imm16/32 NF
XOR_MEMv_IMMz_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 81 /6 iw/id NF=1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, r16/32/64, imm16/32 NDD NF optional
XOR_GPRv_GPRv_IMMz_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 81 /6 iw/id ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, m16/32/64, imm16/32 NDD NF optional
XOR_GPRv_MEMv_IMMz_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 81 /6 iw/id ND=1 NF=0/1 | APX_F + APX_NCI_NDD_NF |
XOR r16/32/64, imm8
XOR_GPRv_IMM8_APX | EVEX.LLZ.NP.MAP4.SCALABLE 83 /6 ib | APX_F |
XOR m16/32/64, imm8
XOR_MEMv_IMM8_APX | EVEX.LLZ.NP.MAP4.SCALABLE 83 /6 ib | APX_F |
XOR r16/32/64, imm8 NF
XOR_GPRv_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 83 /6 ib NF=1 | APX_F + APX_NCI_NDD_NF |
XOR m16/32/64, imm8 NF
XOR_MEMv_IMM8_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 83 /6 ib NF=1 | APX_F + APX_NCI_NDD_NF |
Latency and throughput
| Model | m8, imm8m8, r8XOR m8, imm8XOR m8, r8 | r8, imm8r32, imm32r64, imm32r16, imm8r32, imm8r64, imm8r8, r8r16, r16r32, r32r64, r64 | m16, imm16m32, imm32m64, imm32m16, imm8m32, imm8m64, imm8m16, r16m32, r32m64, r64XOR m16, imm16XOR m32, imm32XOR m64, imm32XOR m16, imm8XOR m32, imm8XOR m64, imm8XOR m16, r16XOR m32, r32XOR m64, r64 | r16, imm16 | r8, m8r16, m16r32, m32 | r64, m64 | AL, imm8rAX, imm32 | rAX, imm16 |
|---|---|---|---|---|---|---|---|---|
| Sandy Bridge | 7 / 1p015 | 1 / 0.33p015 | 7 / 1p015 | 1 / 0.33p015 | 6 / 0.5p015 | 6 / 0.5p015 | 1 / 0.33p015 | 1 / 0.33p015 |
| Haswell, Broadwell, Skylake, Skylake-SP | 7 / 1p0156 | 1 / 0.25p0156 | 7 / 1p0156 | 1 / 0.25p0156 | 6 / 0.5p0156 | 6 / 0.5p0156 | 1 / 0.25p0156 | 1 / 0.25p0156 |
| Ice Lake | 7 / 0.5p0156 | 1 / 0.25p0156 | 7 / 0.5p0156 | 1 / 0.25p0156 | 6 / 0.5p0156 | 6 / 0.5p0156 | 1 / 0.25p0156 | 1 / 0.25p0156 |
| Alder Lake, Sapphire Rapids | 13 / 0.5p0 p1 p5 p6 p11 | 2 / 0.2p0 p1 p5 p6 p11 | 12 / 0.5p0 p1 p5 p6 p11 | 1 / 0.2p0 p1 p5 p6 p11 | 6 / 0.33p0 p1 p5 p6 p11 | 7 / 0.33p0 p1 p5 p6 p11 | 2 / 0.2p0 p1 p5 p6 p11 | 1 / 0.2p0 p1 p5 p6 p11 |
| Lunar Lake | 13 / 0.5p012345 | 2 / 0.17p012345 | 12 / 0.67p135 | 1 / 0.33p135 | 6 / 0.33p012345 | 7 / 0.33p012345 | 2 / 0.17p012345 | 1 / 0.33p135 |
| Bonnell | 1 / 1p0 | 1 / 0.5p01 | 1 / 1p0 | 1 / 0.5p01 | 1 / 1p0 | 1 / 1p0 | 1 / 0.5p01 | 1 / 0.5p01 |
| Silvermont | 5 / 2IEC0 IEC1 MEC | 1 / 0.5IEC0 IEC1 | 5 / 2IEC0 IEC1 MEC | 1 / 0.5IEC0 IEC1 | 4 / 1IEC0 IEC1 MEC | 4 / 1IEC0 IEC1 MEC | 1 / 0.5IEC0 IEC1 | 1 / 0.5IEC0 IEC1 |
| Piledriver | 6 / 2EX0 EX1 | 1 / 1EX0 EX1 | 6 / 2EX0 EX1 | 1 / 1EX0 EX1 | 5 / 1.5EX0 EX1 | 5 / 1.5EX0 EX1 | 1 / 1EX0 EX1 | 1 / 1EX0 EX1 |
| Zen | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
| Zen 2 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
| Zen 3, Zen 4 | 6 / 0.67ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 6 / 0.67ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 1 / 1ALU0 ALU1 ALU2 ALU3 | 1 / 1ALU0 ALU1 ALU2 ALU3 |
| Jaguar | 6 / 1ALU0 ALU1 | 1 / 0.5ALU0 ALU1 | 6 / 1ALU0 ALU1 | 1 / 0.5ALU0 ALU1 | 4 / 1ALU0 ALU1 | 4 / 1ALU0 ALU1 | 1 / 0.5ALU0 ALU1 | 1 / 0.5ALU0 ALU1 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
r = dest ^ sext(src) # with LOCK: one atomic read-modify-write;
# an immediate is sign-extended to OSIZE
if not nf: # NF=1 (APX) leaves the flags as they were
of = cf = 0
sf = msb(r)
zf = r == 0
pf = parity(r)
af = UNDEFINED
dest.write(r) # a 32-bit register: bits 63:32 cleared;
# XOR EAX, EAX zeroes all of RAX
Run on AMD Zen 5 (EPYC 9645): 302 cases. The APX forms were not run: none of these processors has APX. The forms that 64-bit mode lacks were not run: the probe runs in 64-bit mode.
r = src1 ^ sext(src2) # an immediate is sign-extended to OSIZE
if not nf: # NF=1 leaves the flags as they were
of = cf = 0
sf = msb(r)
zf = r == 0
pf = parity(r)
af = UNDEFINED
dest.write(r) # the new destination: bits 63:OSIZE
# cleared, even for 8 and 16 bits
Not run on a processor: none of these processors has APX.
Operands
| Operand | Kind | Action |
|---|---|---|
XOR r/m8, imm8 XOR r/m16/32/64, imm16/32 XOR r/m16/32/64, imm8 LOCK XOR m8, imm8 LOCK XOR m16/32/64, imm16/32 LOCK XOR m16/32/64, imm8 | ||
r/m8/16/32/64 | explicit | read, write |
imm8/16/32 | explicit | read |
RFLAGS | implicit | write |
XOR r/m8, r8 XOR r/m16/32/64, r16/32/64 LOCK XOR m8, r8 LOCK XOR m16/32/64, r16/32/64 | ||
r/m8/16/32/64 | explicit | read, write |
r8/16/32/64 | explicit | read |
RFLAGS | implicit | write |
XOR r8, r/m8 XOR r16/32/64, r/m16/32/64 | ||
r8/16/32/64 | explicit | read, write |
r/m8/16/32/64 | explicit | read |
RFLAGS | implicit | write |
XOR AL, imm8 XOR rAX, imm16/32 | ||
AL, rAX | explicit | read, write |
imm8/16/32 | explicit | read |
RFLAGS | implicit | write |
XOR r/m8, r8 NF XOR r/m16/32/64, r16/32/64 NF | ||
r/m8/16/32/64 | explicit | read, write |
r8/16/32/64 | explicit | read |
XOR r8, r/m8, imm8 NDD NF optional XOR r16/32/64, r/m16/32/64, imm8 NDD NF optional XOR r16/32/64, r/m16/32/64, imm16/32 NDD NF optional | ||
r8/16/32/64 | explicit | write |
r/m8/16/32/64 | explicit | read |
imm8/16/32 | explicit | read |
RFLAGS | implicit | write (NF=0) |
XOR r8, r/m8, r8 NDD NF optional XOR r16/32/64, r/m16/32/64, r16/32/64 NDD NF optional | ||
r8/16/32/64 | explicit | write |
r/m8/16/32/64 | explicit | read |
r8/16/32/64 | explicit | read |
RFLAGS | implicit | write (NF=0) |
XOR r8, m8 NF XOR r16/32/64, m16/32/64 NF | ||
r8/16/32/64 | explicit | read, write |
m8/16/32/64 | explicit | read |
XOR r8, r8, m8 NDD NF optional XOR r16/32/64, r16/32/64, m16/32/64 NDD NF optional | ||
r8/16/32/64 | explicit | write |
r8/16/32/64 | explicit | read |
m8/16/32/64 | explicit | read |
RFLAGS | implicit | write (NF=0) |
XOR r/m8, imm8 NF XOR r/m16/32/64, imm16/32 NF XOR r/m16/32/64, imm8 NF | ||
r/m8/16/32/64 | explicit | read, write |
imm8/16/32 | explicit | read |
Flags
| When | OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|---|
| NF forms | ||||||
| Not affected | ||||||
| NDD forms | ||||||
| NF=0 | 0 | M | M | U | M | 0 |
| Other forms | ||||||
| 0 | M | M | U | M | 0 | |
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- Legacy forms
- none in XED
- EVEX forms
APX-EVEX-INT
Attributes
What else XED records about the forms. How to read.
XOR m8, imm8XOR m8, r8XOR m16/32/64, imm16/32XOR m16/32/64, imm8XOR m16/32/64, r16/32/64- accepts a LOCK prefix
- LOCK forms
- locked: atomic read-modify-write; accepts XACQUIRE; accepts XRELEASE
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 |
|---|---|---|
I86 | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
APX_F | APX_F | Nova Lake, Diamond Rapids |
APX_F_N3 | APX_F + APX_NCI_NDD_NF | Same as APX_F |
More General-purpose instructions
- NEG
- NOP
- NOT
- OR
- OUT
- OUTS
- PAUSE
- POP
- POPA
- POPF
- PUSH
- PUSHA
- PUSHF
- RCL
- RCR
- RET
- ROL
- ROR
- SALC
- SAR
- SBB
- SCAS
- SETcc
- SHL
- SHLD
- SHR
- SHRD
- STC
- STD
- STI
- STOS
- SUB
- TEST
- UD0
- UD1
- UD2
- UDB
- XADD
- XCHG
- XLAT
All 109 General-purpose instructions
More APX instructions
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. - 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 2D, page 6-40 (XOR)
- Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 9.0 (355828-009, August 2026)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
- 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 timings come from LLVM's scheduling models, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.