Instruction
XTEST
Clears ZF inside an RTM or HLE transaction and sets it outside one.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
XTEST tells code whether it is running inside a transaction: it clears ZF inside one, whether XBEGIN started it (RTM) or an XACQUIRE-prefixed lock instruction (HLE, lock elision), and sets ZF outside. CF, OF, SF, PF and AF are cleared either way; no register or memory changes. It is three bytes, 0F 01 D6, with no operands.
Why code asks
Some instructions end every transaction: CPUID and PAUSE on any processor, Intel’s manual says, and on some processors x87 and MMX code, SYSCALL, VZEROUPPER and many more. A function that may be called both inside and outside a transaction, a spin-wait with PAUSE or a call into the kernel, can check XTEST first and take another path, or abort deliberately with XABORT and a code saying why. With HLE, XTEST is the only sign: the elided lock looks taken to the code that holds it, so nothing else shows the difference.
With -mrtm, GCC 14 and Clang 23 at -O2 compile _xtest() to xor eax, eax, xtest and setne al: the intrinsic returns 1 inside a
transaction and 0 outside, the opposite sense of ZF.
Which CPUID bit
Intel’s manual lets XTEST run when the processor has either HLE, CPUID.(EAX=7,ECX=0):EBX[4], or RTM, EBX[11], and raises #UD only when both are clear. XED’s records, and with them this page’s CPUID requirement, ask for RTM alone; its Operation section follows Intel’s manual. So on a processor with HLE and no RTM, XTEST is valid even though XBEGIN is not. XBEGIN’s page says where Intel disables TSX.
AMD’s manual defines no XTEST and marks both bits reserved. On this site’s Zen 5, whose CPUID reports neither, #UD was the result of both recorded cases.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
XTEST
XTEST | NP 0F 01 D6 | RTM |
Latency and throughput
| Model | XTEST |
|---|---|
| Haswell, Broadwell, Skylake, Skylake-SP, Ice Lake | 100 / 0.25p0156 |
| Sapphire Rapids | 100 / 0.6p0 p1 p5 p6 p11 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
r = cpuid_leaf(7, 0)[1]
if not r >> 4 & 1 and not r >> 11 & 1:
fault(UD) # CPUID: neither HLE nor RTM
zf = 0 if rtm_active or hle_active else 1
cf = of = sf = pf = af = 0
# inside a transaction ZF is clear. XED's records ask CPUID for RTM
# alone; Intel's manual takes HLE as wellRun on AMD Zen 5 (EPYC 9645): 2 cases. Its cases ran where CPUID reported no RTM, and every one raised an exception.
Operands
| Operand | Kind | Action |
|---|---|---|
XTEST | ||
RFLAGS | implicit | write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| 0 | 0 | M | 0 | 0 | 0 |
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 |
|---|---|---|
RTM | RTM | Haswell, Broadwell, Skylake, Comet Lake, Cannon Lake, Ice Lake (client), Tiger Lake, Skylake-SP, Cascade Lake, Cooper Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids |
More RTM instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - 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-73 (XTEST)
- 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.38, July 2026)
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.