Instruction
CMOVcc
Copies the source to a register if a condition on the flags holds; APX adds a three-operand form that picks one of two sources.
- Extensions
- Mnemonics
- CMOVO, CMOVNO, CMOVB, CMOVC, CMOVNAE, CMOVNB, CMOVNC, CMOVAE, CMOVZ, CMOVE, CMOVNZ, CMOVNE, CMOVBE, CMOVNA, CMOVNBE, CMOVA, CMOVS, CMOVNS, CMOVP, CMOVPE, CMOVNP, CMOVPO, CMOVL, CMOVNGE, CMOVNL, CMOVGE, CMOVLE, CMOVNG, CMOVNLE, CMOVG
- Forms
- 4 (2 Legacy, 2 EVEX)
- Data
- Intel XED v2026.08.23
CMOVcc copies its source to a register only when a condition on the
flags holds, so code can pick one of two values without a branch. The
condition codes are those of Jcc and
SETcc, and the CMP page shows which to
use for signed and unsigned comparisons. GCC 14 and Clang 23 at -O2
compile a < b ? c : a to a MOV, a CMP and a CMOVL or CMOVGE
(depending on which value each moves first), and both round a signed
division by 8 toward zero with lea rax, [rdi + 7],
test rdi, rdi, cmovns rax, rdi and sar rax, 3.
Branch or CMOVcc
A branch lets the processor guess the outcome and go on; CMOVcc instead makes its result wait for both values and the flags. Intel’s optimization manual therefore recommends CMOVcc only for branches that are hard to predict, and advises against it for predictable ones (Section 3.4.1.1, Coding Rule 2).
What it cannot do
- Skip a memory access. The source is read whether or not the
condition holds, so a load that is only safe when the condition is
true still faults when it is false. Both compilers therefore compile
c ? *p : 0to a branch around the load. APX’s CFCMOVcc suppresses the access and its faults. - Store. The destination is always a register; a conditional store needs a branch, or CFCMOVcc again.
- Bytes and constants. The forms are 16, 32 and 64 bits wide, and the source is a register or memory, so choosing between two constants first puts one of them in a register.
- Leave a 32-bit register alone. A 32-bit CMOVcc clears bits 63:32 of its destination even when the condition is false, so it is never a no-op on a 64-bit value.
Availability and APX
CMOV arrived with Intel’s P6 family and has its own CPUID bit, but every x86-64 processor has it, so 64-bit code uses it without a check. APX adds a form with a new destination, CMOVcc r1, r2, r3/m, which writes r3 to r1 when the condition holds and r2 otherwise: a select that keeps both sources. Its memory operand, too, is read either way.
In the optimization guide
What the optimization guide says about CMOVcc, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Branches
- CMOV and branchless code: CMOVcc and SETcc replace a branch with a data dependence: nothing can be mispredicted, but the result waits for the condition and for both inputs, and the core can no longer run ahead on a guessed path.
- CMOV and branchless code: Branchless code wins when the work it adds costs fewer cycles than the branch it removes costs on average.
- CMOV and branchless code: A CMOV with a memory source always reads it, and may fault on it, even when the condition is false, so it cannot replace a branch that guards a load from a pointer that may be invalid.
- CMOV and branchless code: LLVM 23.1.2 turns CMOVs back into branches where a branch is likely faster.
Haswell and Broadwell
- What Broadwell changed: A micro-op of Haswell’s reads three inputs only for FMA, so ADC, SBB and CMOV, which read two registers and the flags, are two micro-ops each; Broadwell makes them one, though stores and blends stay at two.
Vulnerability mitigations
Mitigations of these processor vulnerabilities use CMOVcc:
- CVE-2021-0086: Floating Point Value Injection
Forms
| Instruction | Encoding | Requires |
|---|---|---|
CMOVcc r16/32/64, m16/32/64
CMOVcc_GPRv_MEMv | 0F 40+cc /r | CMOV |
CMOVcc r16/32/64, r16/32/64
CMOVcc_GPRv_GPRv | 0F 40+cc /r | CMOV |
CMOVcc r16/32/64, r16/32/64, r16/32/64 NDD
CMOVcc_GPRv_GPRv_GPRv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 40+cc /r ND=1 | APX_F + APX_NCI_NDD_NF |
CMOVcc r16/32/64, r16/32/64, m16/32/64 NDD
CMOVcc_GPRv_GPRv_MEMv_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 40+cc /r ND=1 | APX_F + APX_NCI_NDD_NF |
Latency and throughput
| Model | r16, m16r32, m32r64, m64 | r16, m16CMOVBE, CMOVNBEr32, m32CMOVBE, CMOVNBEr64, m64CMOVBE, CMOVNBE | r16, r16r32, r32r64, r64 | r16, r16CMOVBE, CMOVNBEr32, r32CMOVBE, CMOVNBEr64, r64CMOVBE, CMOVNBE |
|---|---|---|---|---|
| Sandy Bridge | 7 / 0.67p015 | 8 / 1p015 | 2 / 0.67p015 | 3 / 1p015 |
| Haswell | 7 / 0.5p0156 | 8 / 0.75p0156 | 2 / 0.5p0156 | 3 / 0.75p0156 |
| Broadwell | 6 / 0.5p06 | 7 / 0.5p0156 | 1 / 0.5p06 | 2 / 0.5p0156 |
| Skylake, Skylake-SP, Ice Lake | 6 / 0.5p06 | 7 / 1p06 | 1 / 0.5p06 | 2 / 1p06 |
| Alder Lake, Sapphire Rapids | 7 / 0.5p06 | 7 / 0.5p06 | 1 / 0.5p06 | 1 / 0.5p06 |
| Lunar Lake | 5 / 1.33p012345 | 5 / 1.33p012345 | 1 / 0.17p012345 | 1 / 0.17p012345 |
| Bonnell | 1 / 1p0 | 1 / 1p0 | 1 / 0.5p01 | 1 / 0.5p01 |
| Silvermont | 5 / 1IEC0 IEC1 MEC | 5 / 1IEC0 IEC1 MEC | 2 / 1IEC0 IEC1 | 2 / 1IEC0 IEC1 |
| Piledriver | 5 / 1.5EX0 EX1 | 5 / 1.5EX0 EX1 | 1 / 0.5EX0 EX1 | 1 / 0.5EX0 EX1 |
| Zen | 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 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
| Zen 3, Zen 4 | 5 / 0.5ALU0 ALU3 | 5 / 0.5ALU0 ALU3 | 1 / 0.5ALU0 ALU3 | 1 / 0.5ALU0 ALU3 |
| Jaguar | 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.
v = src.read() # memory is read, and can fault, even
# when the condition is false
r = v if cond(CC) else dest
dest.write(r) # a 32-bit register gets bits 63:32
# cleared either way
Run on AMD Zen 5 (EPYC 9645): 144 cases.
a = src1.read()
b = src2.read() # memory is read, and can fault, even
# when the condition is false
r = b if cond(CC) else a
dest.write(r) # the new destination: bits 63:OSIZE
# cleared, even for 16 bits
Not run on a processor: none of these processors has APX.
Operands
| Operand | Kind | Action |
|---|---|---|
CMOVcc r16/32/64, r/m16/32/64 | ||
r16/32/64 | explicit | conditional write |
r/m16/32/64 | explicit | read |
RFLAGS | implicit | read |
CMOVcc r16/32/64, r16/32/64, r/m16/32/64 NDD | ||
r16/32/64 | explicit | write |
r16/32/64 | explicit | read |
r/m16/32/64 | explicit | read |
RFLAGS | implicit | read |
Flags
| When | OF | SF | ZF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| CMOVO | T | ||||
| CMOVNO | T | ||||
| CMOVB | T | ||||
| CMOVNB | T | ||||
| CMOVZ | T | ||||
| CMOVNZ | T | ||||
| CMOVBE | T | T | |||
| CMOVNBE | T | T | |||
| CMOVS | T | ||||
| CMOVNS | T | ||||
| CMOVP | T | ||||
| CMOVNP | T | ||||
| CMOVL | T | T | |||
| CMOVNL | T | T | |||
| CMOVLE | T | T | T | ||
| CMOVNLE | T | T | T | ||
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
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 |
|---|---|---|
CMOV | CMOV | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
APX_F_N3 | APX_F + APX_NCI_NDD_NF | Nova Lake, Diamond Rapids |
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 2A, page 3-157 (CMOVcc)
- 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)
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.