Instruction
CTESTscc
APX conditional test: if the flags meet a condition, tests two operands with AND, otherwise sets OF, SF, ZF and CF to a value in the instruction.
- Extensions
- Mnemonics
- CTESTO, CTESTNO, CTESTB, CTESTC, CTESTNAE, CTESTNB, CTESTNC, CTESTAE, CTESTZ, CTESTE, CTESTNZ, CTESTNE, CTESTBE, CTESTNA, CTESTNBE, CTESTA, CTESTS, CTESTNS, CTESTT, CTESTF, CTESTL, CTESTNGE, CTESTNL, CTESTGE, CTESTLE, CTESTNG, CTESTNLE, CTESTG
- Forms
- 8 (8 EVEX)
- Data
- Intel XED v2026.08.23
CTESTscc is a TEST that runs only if a condition on the
current flags holds. It lets a compiler join a == 1 && (b & c) without
a branch: one flag-setting compare, then a test that either updates the
flags from its operands or, when the first half has already failed,
loads them with a value that gives the answer. It is
CCMPscc with TEST in place of CMP, and it writes no
register.
The source condition uses the usual condition codes, with two changes: codes 1010b and 1011b, parity elsewhere, mean always true and always false, so PF cannot be tested. CTESTT is then a plain TEST, and CTESTF just writes the flags.
- If the condition holds, the flags come from
src1 & src2as for TEST: OF and CF cleared, SF, ZF and PF from the result, AF undefined. - If not, OF, SF, ZF and CF take the four-bit default flags value (dfv) in the instruction. PF copies its CF bit and AF is cleared.
The forms match TEST’s: a register or memory operand of 8, 16, 32 or 64 bits with a register or an immediate, which is at most 32 bits and sign-extended at 64. A memory operand is read whatever the condition says, so it can fault; only CFCMOVcc suppresses faults this way.
In our builds
Clang 23 at -O2 with -mapxf compiled a == 1 && (b & c) to cmp edi, 1, cteste {dfv=zf} edx, esi and setzune al. If a is 1 the test
runs; otherwise dfv sets ZF, which SETNE then reads as false. a > 3 || (b & c) became cmp edi, 4 and ctestl {dfv=}, with every default
flag clear, so that SETNE reads true when the first half has decided it.
With a load, a == 1 && (*m & 8), Clang kept a branch, which fits the
rule above. GCC 14 accepts -mapxf but used no CTESTscc in any of
these.
The condition instructions need APX_NCI_NDD_NF as well as APX_F, as the APX page explains.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
CTESTscc {dfv} r8, r8
CTESTscc_GPR8i8_GPR8i8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 84 /r SC=scc | APX_F + APX_NCI_NDD_NF |
CTESTscc {dfv} m8, r8
CTESTscc_MEMi8_GPR8i8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG 84 /r SC=scc | APX_F + APX_NCI_NDD_NF |
CTESTscc {dfv} r16/32/64, r16/32/64
CTESTscc_GPRv_GPRv_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 85 /r SC=scc | APX_F + APX_NCI_NDD_NF |
CTESTscc {dfv} m16/32/64, r16/32/64
CTESTscc_MEMv_GPRv_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE 85 /r SC=scc | APX_F + APX_NCI_NDD_NF |
CTESTscc {dfv} r8, imm8
CTESTscc_GPR8i8_IMM8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG F6 /0 ib SC=sccEVEX.LLZ.NP.MAP4.WIG F6 /1 ib SC=scc | APX_F + APX_NCI_NDD_NF |
CTESTscc {dfv} m8, imm8
CTESTscc_MEMi8_IMM8_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.WIG F6 /0 ib SC=sccEVEX.LLZ.NP.MAP4.WIG F6 /1 ib SC=scc | APX_F + APX_NCI_NDD_NF |
CTESTscc {dfv} r16/32/64, imm16/32
CTESTscc_GPRv_IMMz_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE F7 /0 iw/id SC=sccEVEX.LLZ.NP.MAP4.SCALABLE F7 /1 iw/id SC=scc | APX_F + APX_NCI_NDD_NF |
CTESTscc {dfv} m16/32/64, imm16/32
CTESTscc_MEMv_IMMz_DFV_APX_N3 | EVEX.LLZ.NP.MAP4.SCALABLE F7 /0 iw/id SC=sccEVEX.LLZ.NP.MAP4.SCALABLE F7 /1 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.
r = src1 & sext(src2) # memory is read, and can fault, even
# when the condition is false
if cond(CC):
of = cf = 0 # as TEST src1, src2
sf = msb(r)
zf = r == 0
pf = parity(r)
af = UNDEFINED
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 |
|---|---|---|
CTESTscc {dfv} r/m8, r8 CTESTscc {dfv} r/m16/32/64, r16/32/64 | ||
r/m8/16/32/64 | explicit | read |
r8/16/32/64 | explicit | read |
RFLAGS | implicit | write |
CTESTscc {dfv} r/m8, imm8 CTESTscc {dfv} r/m16/32/64, imm16/32 | ||
r/m8/16/32/64 | explicit | read |
imm8/16/32 | explicit | read |
RFLAGS | implicit | write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| 0 | M | M | U | M | 0 |
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.