Extensions
Forms
6 (6 Legacy)
Data
Intel XED v2026.08.23

BTC copies one bit of its first operand into CF and then inverts that bit. The bit is chosen as BT chooses it, and ZF stays as it was. Of the three bit-modifying siblings it is the least used: BTS sets and BTR clears, and both have obvious uses as locks and claims. Flipping is for toggles: a phase bit that alternates between two buffers, or the sign bit of an integer.

The new value from the old

CF holds the bit as it was, so after BTC the bit as it is now is the inverse of CF. GCC 14 and Clang 23 at -O2 compile the atomic toggle __atomic_xor_fetch(p, m, __ATOMIC_SEQ_CST) & m, with m being 1UL << (n & 63), to and esi, 63, lock btc qword ptr [rdi], rsi and setnc al (Clang prints setae al): the condition is inverted, not the instruction. With __atomic_fetch_xor, which returns the old value, they use SETC as for BTS. The AND stays because a memory operand does not reduce the bit number modulo 64.

On registers

x ^ (1UL << n) becomes btc rax, rsi with both compilers. For the sign bit of a 64-bit value, x ^ (1UL << 63), GCC emits btc rax, 63, and Clang a 10-byte MOVABS of the mask and an XOR. For a 32-bit x ^ 0x80000000, both use lea eax, [rdi - 2147483648]: adding 2^31 flips bit 31 too, and LEA writes the result to another register without touching the flags.

Things to know

  • Speed. AMD’s Zen 5 instruction table lists the register forms of BTC as 2 macro-ops and every memory form as microcoded; for plain memory, compilers flip a bit with an XOR to memory instead.
  • LOCK is accepted only with a memory destination, and raises #UD on a register.
  • Undefined flags. OF, SF, AF and PF are undefined; Zen 5 left them as they were in all 168 recorded cases.

Forms

Every encoding of BTC that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
BTC m16/32/64, imm8 BTC_MEMv_IMMb0F BA /7 ibBase instruction set
BTC r16/32/64, imm8 BTC_GPRv_IMMb0F BA /7 ibBase instruction set
BTC m16/32/64, r16/32/64 BTC_MEMv_GPRv0F BB /rBase instruction set
BTC r16/32/64, r16/32/64 BTC_GPRv_GPRv0F BB /rBase instruction set
LOCK BTC m16/32/64, imm8 BTC_LOCK_MEMv_IMMb0F BA /7 ibBase instruction set
LOCK BTC m16/32/64, r16/32/64 BTC_LOCK_MEMv_GPRv0F BB /rBase instruction set

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.
Modelm16, imm8
m32, imm8
m64, imm8
BTC m16, imm8
BTC m32, imm8
BTC m64, imm8
r16, imm8
r32, imm8
r64, imm8
r16, r16
r32, r32
m16, r16
m32, r32
BTC m16, r16
BTC m32, r32
m64, r64
BTC m64, r64
r64, r64
Sandy Bridge7 / 1p051 / 0.5p059 / 1p0159 / 1p0151 / 0.5p05
Haswell7 / 1p061 / 0.5p061 / 2.751 / 2.751 / 0.5p06
Broadwell, Skylake, Skylake-SP6 / 1p061 / 0.5p066 / 1p01566 / 1p01561 / 0.5p06
Ice Lake6 / 0.5p061 / 0.5p066 / 0.5p01566 / 0.5p01561 / 0.5p06
Alder Lake, Sapphire Rapids12 / 1p11 / 1p118 / 1.6p0 p1 p5 p6 p1117 / 1.4p0 p1 p5 p6 p113 / 1p1
Lunar Lake12 / 0.5p1351 / 0.33p13518 / 1.33p01234517 / 1.17p0123453 / 1p1
Bonnell2 / 1p11 / 1p111 / 5.5p111 / 5.5p11 / 1p1
Silvermont4 / 2IEC0 IEC1 MEC1 / 1IEC0 IEC14 / 2IEC0 IEC1 MEC4 / 2IEC0 IEC1 MEC1 / 1IEC0 IEC1
Piledriver7 / 21EX0 EX12 / 1EX0 EX17 / 22EX0 EX17 / 22EX0 EX12 / 1EX0 EX1
Zen6 / 0.5ALU0 ALU1 ALU2 ALU32 / 0.25ALU0 ALU1 ALU2 ALU36 / 0.5ALU0 ALU1 ALU2 ALU36 / 0.5ALU0 ALU1 ALU2 ALU32 / 0.25ALU0 ALU1 ALU2 ALU3
Zen 26 / 0.33ALU0 ALU1 ALU2 ALU32 / 0.25ALU0 ALU1 ALU2 ALU36 / 0.33ALU0 ALU1 ALU2 ALU36 / 0.33ALU0 ALU1 ALU2 ALU32 / 0.25ALU0 ALU1 ALU2 ALU3
Zen 3, Zen 47 / 0.67ALU1 ALU22 / 1ALU1 ALU27 / 0.67ALU1 ALU27 / 0.67ALU1 ALU22 / 1ALU1 ALU2
Jaguar6 / 1ALU0 ALU11 / 0.5ALU0 ALU16 / 1ALU0 ALU16 / 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.

BTC r/m16/32/64, imm8 BTC r16/32/64, r16/32/64 LOCK BTC m16/32/64, imm8
n = bit & (OSIZE - 1)            # the offset, modulo the operand size
v = dest.read()                  # with LOCK: one atomic read-modify-write
cf = v >> n & 1
of = sf = af = pf = UNDEFINED    # ZF keeps its value
dest.write(v ^ 1 << n)           # a 32-bit register: bits 63:32 cleared

Run on AMD Zen 5 (EPYC 9645): 99 cases.

BTC m16/32/64, r16/32/64 LOCK BTC m16/32/64, r16/32/64
n = signed(bit)                  # not masked: bit n can lie far below
                                 # or above the operand
a = dest.address + n // OSIZE * (OSIZE // 8)   # the OSIZE bits that
v = load(a, OSIZE)                             # hold it; with LOCK,
cf = v >> n % OSIZE & 1                        # read and written as one
of = sf = af = pf = UNDEFINED    # ZF keeps its value
store(a, OSIZE, v ^ 1 << n % OSIZE)

Run on AMD Zen 5 (EPYC 9645): 69 cases.

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
BTC r/m16/32/64, imm8 LOCK BTC m16/32/64, imm8
r/m16/32/64explicitread, write
imm8explicitread
RFLAGSimplicitwrite
BTC r/m16/32/64, r16/32/64 LOCK BTC m16/32/64, r16/32/64
r/m16/32/64explicitread, write
r16/32/64explicitread
RFLAGSimplicitwrite

Flags

M modified, U undefined; blank: not affected. How to read.
OFSFAFPFCF
All forms
UUUUM

Attributes

What else XED records about the forms. How to read.

Memory forms without LOCK
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.

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
I386

No CPUID bit: part of the base instruction set.

Every x86-64 processor in XED’s model and Zen 3 to Zen 6

More General-purpose instructions

All 109 General-purpose 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. LLVM 23.1.2's x86 scheduling models (commit 85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them.
  4. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-114 (BTC)
  5. AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
  6. 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.