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

BT copies one bit of its first operand into CF, where JC, JNC, SETC, CMOVC or ADC can use it. BTS, BTR and BTC copy the bit the same way and then set, clear or flip it. Clang 23 at -O2 compiles if (x & (1ULL << n)) on a 64-bit x to bt rdi, rsi and a CMOVAE, and the test of a fixed bit 40 to bt rdi, 40, which spares it a 10-byte MOV of the mask. GCC 14 tests such bits with shifts and ANDs, but sets and clears bit n of a register with BTS and BTR.

How far the offset reaches

On a register, the bit number is taken modulo the operand size, 16, 32 or 64, and an immediate does the same on memory, so it selects a bit within the operand itself.

A register offset on a memory operand is different. The address then marks only bit 0 of a bit string, and the offset is a signed number, not masked, that can select a bit far below or above it: up to 2^63 bits either way with a 64-bit offset. The processor reads the 2, 4 or 8 bytes, by operand size, that hold the bit. This site’s Zen 5 ran cases reaching 64 bytes below and above the address, so bt [rdi], rsi tests bit RSI of a whole array at RDI.

Cautions

  • The access is wider than the bit. It covers a word of the operand’s size around the bit, so near memory-mapped I/O, or at the edge of mapped memory, Intel’s and AMD’s manuals advise a MOV and a BT on the register instead.
  • Speed. The instruction table that comes with AMD’s Zen 5 guide lists BT with a memory operand and a register offset as microcoded, while the register and immediate forms are single macro-ops. Neither compiler uses it at -O2: for (a[n / 64] >> (n % 64)) & 1, both load the word with a MOV, and Clang then runs bt rcx, rsi on the register.
  • No LOCK. BT only reads, and a LOCK prefix raises #UD; the atomic test-and-modify forms are LOCK BTS, LOCK BTR and LOCK BTC.

BT leaves ZF as it was, so code cannot use the zero flag to learn the bit; the flags table shows the others.

In the optimization guide

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

Out of order

Forms

Every encoding of BT that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
BT m16/32/64, imm8 BT_MEMv_IMMb0F BA /4 ibBase instruction set
BT r16/32/64, imm8 BT_GPRv_IMMb0F BA /4 ibBase instruction set
BT m16/32/64, r16/32/64 BT_MEMv_GPRv0F A3 /rBase instruction set
BT r16/32/64, r16/32/64 BT_GPRv_GPRv0F A3 /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
r16, imm8
r32, imm8
r64, imm8
r16, r16
r32, r32
m16, r16
m32, r32
m64, r64r64, r64
Sandy Bridge6 / 0.5p051 / 0.5p059 / 1p0159 / 1p0151 / 0.5p05
Haswell6 / 0.5p061 / 0.5p061 / 2.51 / 2.51 / 0.5p06
Broadwell, Skylake, Skylake-SP, Ice Lake6 / 0.5p061 / 0.5p066 / 0.5p01566 / 0.5p01561 / 0.5p06
Alder Lake, Sapphire Rapids6 / 1p11 / 1p111 / 1.8p0 p1 p5 p6 p1110 / 1.6p0 p1 p5 p6 p113 / 1p1
Lunar Lake6 / 0.33p1351 / 0.33p13511 / 1.5p01234510 / 1.33p0123453 / 1p1
Bonnell1 / 1p01 / 1p19 / 4.5p19 / 4.5p11 / 1p1
Silvermont4 / 1IEC0 IEC1 MEC1 / 1IEC0 IEC14 / 1IEC0 IEC1 MEC4 / 1IEC0 IEC1 MEC1 / 1IEC0 IEC1
Piledriver5 / 1.5EX0 EX11 / 1EX0 EX15 / 3.5EX0 EX15 / 3.5EX0 EX11 / 1EX0 EX1
Zen5 / 0.5ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 0.5ALU0 ALU1 ALU2 ALU35 / 0.5ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU3
Zen 25 / 0.33ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 0.33ALU0 ALU1 ALU2 ALU35 / 0.33ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU3
Zen 3, Zen 45 / 0.5ALU1 ALU21 / 0.5ALU1 ALU25 / 0.5ALU1 ALU25 / 0.5ALU1 ALU21 / 0.5ALU1 ALU2
Jaguar4 / 1ALU0 ALU11 / 0.5ALU0 ALU14 / 1ALU0 ALU14 / 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.

BT r/m16/32/64, imm8 BT r16/32/64, r16/32/64
n = bit & (OSIZE - 1)            # the offset, modulo the operand size
cf = base >> n & 1
of = sf = af = pf = UNDEFINED    # ZF keeps its value

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

BT m16/32/64, r16/32/64
n = signed(bit)                  # not masked: bit n can lie far below
                                 # or above the operand
a = base.address + n // OSIZE * (OSIZE // 8)   # the OSIZE bits that
cf = load(a, OSIZE) >> n % OSIZE & 1           # hold it
of = sf = af = pf = UNDEFINED    # ZF keeps its value

Run on AMD Zen 5 (EPYC 9645): 51 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
BT r/m16/32/64, imm8
r/m16/32/64explicitread
imm8explicitread
RFLAGSimplicitwrite
BT r/m16/32/64, r16/32/64
r/m16/32/64explicitread
r16/32/64explicitread
RFLAGSimplicitwrite

Flags

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

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-112 (BT)
  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.