Instruction
VCMPSH
Compares the low half-precision values with one of 32 predicates chosen by an immediate and writes the result to a mask register.
- Extensions
- Forms
- 2 (2 EVEX)
- Data
- Intel XED v2026.08.23
VCMPSH compares the low halves of its two sources under one of the 32
predicates of VCMPPS, chosen by bits 4:0 of the
immediate, and writes the result to bit 0 of a mask register, clearing
the others; a write mask with bit 0 clear forces the result to 0. It is
the scalar form of VCMPPH and, like the EVEX form of
VCMPSS, has only a mask destination. The encoding is
C2h with the F3 prefix in the 0F3A map; the second source is an xmm
register or two bytes of memory, and {sae} keeps the compare from
reporting invalid or denormal. VADDPH covers the format
and the CPUID bits.
Selects and the comi intrinsics
A mask bit feeds a masked move, so compilers use VCMPSH for a choice
between two halves. At -O2 with -march=x86-64-v4 -mavx512fp16, Clang
23 compiles x < y ? p : q on _Float16 values to vcmpltsh k1, xmm0, xmm1 and a merge-masked VMOVSH, and x == y ? p : q
the same way with the equal predicate. GCC 14 uses VCMPSH for the first
too, with the inverted predicate 5, not less than, so that the masked
move picks q; for the equality it tests the flags of
VUCOMISH and branches. Clang’s fminf16 on halves
uses VCMPSH with the unordered predicate to catch a NaN first argument,
as VMINSH’s page shows.
A plain x < y returned as an integer goes to the flags instead, as
VCOMISH’s page shows. The intrinsics named after
COMISH do not: _mm_comi_sh(x, y, _CMP_LT_OS) and _mm_cmp_sh_mask(x, y, _CMP_NEQ_UQ) both become VCMPSH into K0, with predicates 1 and 4,
and a KMOV of the bit to a general-purpose register.
AMD’s Zen 5 guide does not list AVX512-FP16, and this site’s recorded cases include none of VCMPSH.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VCMPSH k {k}, xmm, xmm, imm8, {sae}
VCMPSH_MASKmskw_MASKmskw_XMMf16_XMMf16_IMM8_AVX512 | EVEX.LIG.F3.0F3A.W0 C2 /r ib | AVX10.1 or AVX512_FP16 |
VCMPSH k {k}, xmm, m16, imm8
VCMPSH_MASKmskw_MASKmskw_XMMf16_MEMf16_IMM8_AVX512 | EVEX.LIG.F3.0F3A.W0 C2 /r ib | AVX10.1 or AVX512_FP16 |
Latency and throughput
| Model | k {k}, xmm, xmm, imm8, {sae}no mask, with a mask | k {k}, xmm, xmm, imm8, {sae}with {sae} | k {k}, xmm, m16, imm8 |
|---|---|---|---|
| Sapphire Rapids | 3 / 1p5 | 4 / 0.5p01 | 3 / 1p5 |
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.
Where bit 0 of the write mask k2 is 0, the result bit is 0.
The result comes from half 0 of xmm2 and xmm3. Result bits 7 to 0: 0, 0, 0, 0, 0, 0, 0, r0.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
a = xmm2.f16[0]
b = src3.f16[0]
k1[0] = k2[0] and fcmp(imm8, a, b)
# imm8 & 31: 0 ==, 1 <, 2 <=, 3 unordered, 4 !=, 5 !<, 6 !<=, 7 ordered ...
# {sae}: no exception flags
# the other bits of k1 are clearedNot run on a processor: none of these processors has AVX512-FP16.
Operands
| Operand | Kind | Action |
|---|---|---|
VCMPSH k {k}, xmm, xmm/m16, imm8, {sae} | ||
k | explicit | write (masked) |
{k} | explicit | read (write mask) |
xmm | explicit | read |
xmm/m16 | 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
AVX512-E3
Attributes
What else XED records about the forms. How to read.
- All forms
- write masking; follows MXCSR
- Memory forms
- memory fault suppression
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VCMPSH, 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_round_sh_mask
__mmask8 _mm_cmp_round_sh_mask(__m128h X, __m128h Y, const int P, const int R) |
|
_mm_cmp_sh_mask
__mmask8 _mm_cmp_sh_mask(__m128h X, __m128h Y, const int P) |
|
_mm_comi_round_sh
int _mm_comi_round_sh(__m128h A, __m128h B, const int P, const int R) |
|
_mm_comi_sh
int _mm_comi_sh(__m128h A, __m128h B, const int pred) |
|
_mm_comieq_sh
int _mm_comieq_sh(__m128h __A, __m128h __B) |
|
_mm_comige_sh
int _mm_comige_sh(__m128h __A, __m128h __B) |
|
_mm_comigt_sh
int _mm_comigt_sh(__m128h __A, __m128h __B) |
|
_mm_comile_sh
int _mm_comile_sh(__m128h __A, __m128h __B) |
|
_mm_comilt_sh
int _mm_comilt_sh(__m128h __A, __m128h __B) |
|
_mm_comineq_sh
int _mm_comineq_sh(__m128h __A, __m128h __B) |
|
_mm_ucomieq_sh
int _mm_ucomieq_sh(__m128h __A, __m128h __B) |
|
_mm_ucomige_sh
int _mm_ucomige_sh(__m128h __A, __m128h __B) |
|
_mm_ucomigt_sh
int _mm_ucomigt_sh(__m128h __A, __m128h __B) |
|
_mm_ucomile_sh
int _mm_ucomile_sh(__m128h __A, __m128h __B) |
|
_mm_ucomilt_sh
int _mm_ucomilt_sh(__m128h __A, __m128h __B) |
|
_mm_ucomineq_sh
int _mm_ucomineq_sh(__m128h __A, __m128h __B) |
|
_mm_mask_cmp_round_sh_mask
__mmask8 _mm_mask_cmp_round_sh_mask(__mmask8 M, __m128h X, __m128h Y, const int P, const int R) |
|
_mm_mask_cmp_sh_mask
__mmask8 _mm_mask_cmp_sh_mask(__mmask8 M, __m128h X, __m128h Y, const int P) |
|
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 |
|---|---|---|
AVX512_FP16_SCALAR | AVX10.1 or AVX512_FP16 | Nova Lake, Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Zen 6 |
More AVX10.1 instructions
- VANDPD
- VANDPS
- VBLENDMPD
- VBLENDMPS
- VBROADCASTF32X2
- VBROADCASTF32X4
- VBROADCASTF32X8
- VBROADCASTF64X2
- VBROADCASTF64X4
- VBROADCASTI32X2
- VBROADCASTI32X4
- VBROADCASTI32X8
- VBROADCASTI64X2
- VBROADCASTI64X4
- VBROADCASTSD
- VBROADCASTSS
- VCMPPD
- VCMPPH
- VCMPPS
- VCMPSD
- VCMPSS
- VCOMISD
- VCOMISH
- VCOMISS
- VCOMPRESSPD
- VCOMPRESSPS
- VCVTDQ2PD
- VCVTDQ2PH
- VCVTDQ2PS
- VCVTNE2PS2BF16
- VCVTNEPS2BF16
- VCVTPD2DQ
- VCVTPD2PH
- VCVTPD2PS
- VCVTPD2QQ
- VCVTPD2UDQ
- VCVTPD2UQQ
- VCVTPH2DQ
- VCVTPH2PD
- VCVTPH2PS
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. - 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 Advanced Vector Extensions 10.2 Architecture Specification, revision 7.0 (361050-007, April 2026)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2C, page 5-22 (VCMPSH)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
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 and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.