Instruction
CMPccXADD
Atomically compares memory with a register, adds a second register to memory if the condition holds, and returns the old value in the first.
- Extensions
- Mnemonics
- CMPOXADD, CMPNOXADD, CMPBXADD, CMPCXADD, CMPNAEXADD, CMPNBXADD, CMPNCXADD, CMPAEXADD, CMPZXADD, CMPEXADD, CMPNZXADD, CMPNEXADD, CMPBEXADD, CMPNAXADD, CMPNBEXADD, CMPAXADD, CMPSXADD, CMPNSXADD, CMPPXADD, CMPPEXADD, CMPNPXADD, CMPPOXADD, CMPLXADD, CMPNGEXADD, CMPNLXADD, CMPGEXADD, CMPLEXADD, CMPNGXADD, CMPNLEXADD, CMPGXADD
- Forms
- 4 (2 VEX, 2 EVEX)
- Data
- Intel XED v2026.08.23
CMPccXADD m, r1, r2 performs these steps as one locked operation:
- Read the memory value and compare it with r1, setting the flags as CMP would (memory minus r1).
- If the condition cc holds for those flags, write the memory value plus r2 back to memory; otherwise leave memory unchanged.
- Put the original memory value in r1.
Without it, a conditional atomic update such as “increment the counter unless it has reached the limit” needs a loop around LOCK CMPXCHG that retries whenever another thread changed the value in between. CMPccXADD always completes in one step and returns the old value and the flags of the comparison, so the caller knows whether the addition happened. The lock is implicit, a LOCK prefix is not allowed, and the memory operand cannot be a register.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
CMPccXADD m32, r32, r32 64-bit mode only
CMPccXADD_MEMu32_GPR32u32_GPR32u32 | VEX.LZ.66.0F38.W0 E0+cc /r | CMPCCXADD |
CMPccXADD m64, r64, r64 64-bit mode only
CMPccXADD_MEMu64_GPR64u64_GPR64u64 | VEX.LZ.66.0F38.W1 E0+cc /r | CMPCCXADD |
CMPccXADD m32, r32, r32
CMPccXADD_MEMu32_GPR32u32_GPR32u32_APX | EVEX.LLZ.66.0F38.W0 E0+cc /r | APX_F + CMPCCXADD |
CMPccXADD m64, r64, r64
CMPccXADD_MEMu64_GPR64u64_GPR64u64_APX | EVEX.LLZ.66.0F38.W1 E0+cc /r | APX_F + CMPCCXADD |
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to CMPccXADD, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.
| Intrinsic | Compiles to |
|---|---|
_cmpccxadd_epi32
int _cmpccxadd_epi32(void *__A, int __B, int __C, const int __D) |
|
_cmpccxadd_epi64
long long _cmpccxadd_epi64(long long *__A, long long __B, long long __C, const int __D) |
|
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 in XED |
|---|---|---|
CMPCCXADD | CMPCCXADD | Arrow Lake, Panther Lake, Nova Lake, Diamond Rapids, Sierra Forest, Clearwater Forest |
APX_F_CMPCCXADD | APX_F + CMPCCXADD | Nova Lake, Diamond Rapids |
More APX instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, ISA sets, CPUID bits and chip model. - Clang's x86 intrinsic headers, LLVM 23.1.2 (commit
85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-092, June 2026)
- Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 7.0 (July 2025)
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 intrinsics and their signatures come from Clang, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.