Instruction
CMPPS
Compares four packed singles with one of eight predicates an immediate selects, into all-ones or all-zeros elements.
- Extensions
- Forms
- 2 (2 Legacy)
- Data
- Intel XED v2026.08.23
CMPPS compares the four singles of its first operand with those of the second and replaces each element of the first with all ones where the predicate holds and zero where it does not. The immediate chooses the predicate, and the legacy form reads only its bits 2:0, which give the eight below; a, the first operand, stands on the left of each relation. VCMPPS adds 24 predicates with bits 3 and 4 and can write a mask register; CMPPD, CMPSS and CMPSD use the same eight codes for doubles and single elements.
The eight predicates
| Imm | Mnemonic | True when | NaN gives | QNaN sets IE |
|---|---|---|---|---|
| 0 | CMPEQPS | a = b | false | no |
| 1 | CMPLTPS | a < b | false | yes |
| 2 | CMPLEPS | a <= b | false | yes |
| 3 | CMPUNORDPS | a or b is NaN | true | no |
| 4 | CMPNEQPS | not a = b | true | no |
| 5 | CMPNLTPS | not a < b | true | yes |
| 6 | CMPNLEPS | not a <= b | true | yes |
| 7 | CMPORDPS | neither is NaN | false | no |
A signaling NaN sets IE under every predicate. The negations are not
the reversed relations: NLT differs from “greater or equal” exactly
where a NaN makes the result true. There is no greater-than code:
_mm_cmpgt_ps(a, b) compiles in our builds to cmpltps xmm1, xmm0, b
first, and a MOVAPS back to XMM0, as the result replaces the first
operand. The other legacy traits apply too:
bits 128 and up stay (see SSE and AVX)
and a memory operand must be aligned to 16 bytes.
On Zen 5
cmpps xmm4, xmm4, 0x8acted as predicate 0: a quiet NaN compared unequal to itself and set no flag, where VCMPPS’s predicate 8 would have returned true.cmpps xmm7, xmm11, 0x3, unordered, set DE for denormal inputs as well as IE for a signaling NaN;cmpps xmm8, xmm15, 0x7, ordered, set DE alone.- With IE unmasked,
cmpps xmm0, xmm13, 0x5set IE, raised #XM for a signaling NaN and left XMM0 as it was.
In baseline code
In our builds at -O2 for the default target, Clang 23 vectorizes
compares over float arrays with CMPPS: < as CMPLTPS, > as CMPLTPS
with the operands swapped, >= as CMPLEPS swapped, == as CMPEQPS,
!= as CMPNEQPS, and isnan(x) and isunordered as CMPUNORDPS. A
select between two values adds ANDPS,
ANDNPS and ORPS, or one
BLENDVPS with -march=x86-64-v2. Like VCMPPS’s
loops, isless used the signaling CMPLTPS. GCC 14 kept the same loops
scalar, with COMISS and UCOMISS.
Forms
Data flow
Where the elements of the sources go, element 0 on the right; results that depend on a control value are drawn for an example. How to read.
Result single i comes from single i of xmm1 and xmm2. Result singles 3 to 0: r3, r2, r1, r0.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
for i in range(4):
a = xmm1.f32[i]
b = src2.f32[i]
if fcmp(imm8 & 7, a, b):
xmm1.d[i] = -1
else:
xmm1.d[i] = 0
# imm8 & 7: 0 ==, 1 <, 2 <=, 3 unordered, 4 !=, 5 !<, 6 !<=, 7 ordered
# bits 128 and up of the register are unchangedRun on AMD Zen 5 (EPYC 9645): 13 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
CMPPS xmm, xmm/m128, imm8 | ||
xmm | explicit | read, write |
xmm/m128 | explicit | read |
imm8 | explicit | read |
Flags
None: XED records no flag that the forms test or change.
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- All forms
SSE_TYPE_2
Attributes
What else XED records about the forms. How to read.
- All forms
- follows MXCSR
- Memory forms
- aligned memory operand
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to CMPPS, 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 |
|---|---|
_mm_cmp_ps
__m128 _mm_cmp_ps(__m128 a, __m128 b, const int c) |
|
_mm_cmpeq_ps
__m128 _mm_cmpeq_ps(__m128 __a, __m128 __b) |
|
_mm_cmpge_ps
__m128 _mm_cmpge_ps(__m128 __a, __m128 __b) |
|
_mm_cmpgt_ps
__m128 _mm_cmpgt_ps(__m128 __a, __m128 __b) |
|
_mm_cmple_ps
__m128 _mm_cmple_ps(__m128 __a, __m128 __b) |
|
_mm_cmplt_ps
__m128 _mm_cmplt_ps(__m128 __a, __m128 __b) |
|
_mm_cmpneq_ps
__m128 _mm_cmpneq_ps(__m128 __a, __m128 __b) |
|
_mm_cmpnge_ps
__m128 _mm_cmpnge_ps(__m128 __a, __m128 __b) |
|
_mm_cmpngt_ps
__m128 _mm_cmpngt_ps(__m128 __a, __m128 __b) |
|
_mm_cmpnle_ps
__m128 _mm_cmpnle_ps(__m128 __a, __m128 __b) |
|
_mm_cmpnlt_ps
__m128 _mm_cmpnlt_ps(__m128 __a, __m128 __b) |
|
_mm_cmpord_ps
__m128 _mm_cmpord_ps(__m128 __a, __m128 __b) |
|
_mm_cmpunord_ps
__m128 _mm_cmpunord_ps(__m128 __a, __m128 __b) |
|
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 |
|---|---|---|
SSE | SSE | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More SSE 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. - 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-093, September 2026): Volume 2A, page 3-175 (CMPPS)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 4: 128-Bit and 256-Bit Media Instructions (26568, rev. 3.25, November 2021), Wayback Machine copy of AMD's PDF
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.