Instruction
CCMPscc
APX conditional compare: if the flags meet a condition, compares two operands, otherwise sets OF, SF, ZF and CF to a value in the instruction.
- Extensions
- Mnemonics
- CCMPO, CCMPNO, CCMPB, CCMPC, CCMPNAE, CCMPNB, CCMPNC, CCMPAE, CCMPZ, CCMPE, CCMPNZ, CCMPNE, CCMPBE, CCMPNA, CCMPNBE, CCMPA, CCMPS, CCMPNS, CCMPT, CCMPF, CCMPL, CCMPNGE, CCMPNL, CCMPGE, CCMPLE, CCMPNG, CCMPNLE, CCMPG
- Forms
- 12 (12 EVEX)
- Data
- Intel XED v2026.08.23
CCMPscc lets a compiler evaluate a chain of comparisons such as
a == 1 && b > c without a branch per term. The source condition
(scc, one of the usual condition codes) is tested against the current
flags:
- If it holds, the instruction is an ordinary CMP and sets the flags from the comparison.
- If it does not, the comparison is skipped. OF, SF, ZF and CF are set from the four-bit default flags value (dfv) in the instruction, PF is set equal to CF, and AF is cleared.
Two extra condition codes replace the parity conditions: T (always true) makes CCMPT an ordinary compare, and F (always false) sets the flags to dfv unconditionally. A memory operand may fault even when the condition is false. CTESTscc is the same idea for TEST.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
CCMPscc {dfv} r8, r8
CCMPscc_GPR8i8_GPR8i8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 38 /r SC=sccEVEX.LLZ.NP.MAP4.WIG 3A /r SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} m8, r8
CCMPscc_MEMi8_GPR8i8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 38 /r SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} r16/32/64, imm8
CCMPscc_GPRv_IMM8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 83 /7 ib SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} m16/32/64, imm8
CCMPscc_MEMv_IMM8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 83 /7 ib SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} r16/32/64, r16/32/64
CCMPscc_GPRv_GPRv_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 39 /r SC=sccEVEX.LLZ.NP.MAP4.SCALABLE 3B /r SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} m16/32/64, r16/32/64
CCMPscc_MEMv_GPRv_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 39 /r SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} r8, m8
CCMPscc_GPR8i8_MEMi8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 3A /r SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} r16/32/64, m16/32/64
CCMPscc_GPRv_MEMv_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 3B /r SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} r8, imm8
CCMPscc_GPR8i8_IMM8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 80 /7 ib SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} m8, imm8
CCMPscc_MEMi8_IMM8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 80 /7 ib SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} r16/32/64, imm16/32
CCMPscc_GPRv_IMMz_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 81 /7 iw/id SC=scc | APX_F + APX_NCI_NDD_NF |
CCMPscc {dfv} m16/32/64, imm16/32
CCMPscc_MEMv_IMMz_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 81 /7 iw/id SC=scc | APX_F + APX_NCI_NDD_NF |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
a = src1.read() # memory is read, and can fault, even
b = sext(src2) # when the condition is false
if cond(CC):
flags = sub_flags(a, b) # as CMP src1, src2
else:
of = dfv >> 3 & 1 # the flags of {dfv}
sf = dfv >> 2 & 1
zf = dfv >> 1 & 1
cf = dfv & 1
pf = dfv & 1 # PF as CF
af = 0Not run on a processor: none of these processors has APX.
Operands
| Operand | Kind | Action |
|---|---|---|
CCMPscc {dfv} r/m8, r8 CCMPscc {dfv} r/m16/32/64, r16/32/64 | ||
r/m8/16/32/64 | explicit | read |
r8/16/32/64 | explicit | read |
RFLAGS | implicit | write |
CCMPscc {dfv} r/m8, imm8 CCMPscc {dfv} r/m16/32/64, imm8 CCMPscc {dfv} r/m16/32/64, imm16/32 | ||
r/m8/16/32/64 | explicit | read |
imm8/16/32 | explicit | read |
RFLAGS | implicit | write |
CCMPscc {dfv} r8, m8 CCMPscc {dfv} r16/32/64, m16/32/64 | ||
r8/16/32/64 | explicit | read |
m8/16/32/64 | explicit | read |
RFLAGS | implicit | write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| M | M | M | M | M | M |
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- All forms
APX-EVEX-CCMP
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 |
|---|---|---|
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. - Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 9.0 (355828-009, August 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 text is our own.