Instruction
VCVTPS2PH
Converts packed singles to half precision, rounding as an immediate or MXCSR selects.
VCVTPS2PH narrows singles to half precision: four from an XMM register or eight from a YMM register, into the low half of an XMM register or straight to memory. It is the F16C partner of VCVTPH2PS, and unlike that one it rounds: a half has 11 significant bits and a largest finite value of 65504.
The immediate
Its immediate chooses the rounding: with bit 2 clear, bits 1:0 give it
(00 nearest, 01 down, 10 up, 11 toward zero); with bit 2 set, MXCSR.RC
decides. Intel’s manual says that bits 7:3 are ignored and AMD’s says
nothing of them; Zen 5 ignored them, converting with 08h as with 00h
and with FCh as with 04h. GCC 14 and Clang 23 at -O2 with -mf16c use
4 for C’s conversion of a float to _Float16, so the program’s
rounding mode applies; _cvtss_sh(x, 0) gets 0.
Out of range
Both manuals say that MXCSR.FTZ has no effect: results below the smallest normal half become half denormals. Zen 5 agreed, rounding the single 00000001h up to the half 0001h with FTZ set, and setting UE, PE and DE. Rounding to nearest turns 65520 and more into infinity, with OE and PE set; rounding toward zero never goes past 65504. A NaN keeps the top bits of its payload: 7FC12345h became 7E09h. With an exception unmasked, the instruction raises #XM and writes nothing, which the cases recorded on Zen 5 show for a signaling NaN input.
In compiled code
A loop narrowing an array of floats to _Float16 becomes the YMM form
with a memory destination in Clang; GCC converts each element alone and
stores it with VPEXTRW. Intel’s optimization manual found the
instruction about four times faster than converting with integer
instructions (Example 15-32). A double is not narrowed through a
single, which could round twice: both compilers call the library’s
__truncdfhf2 for it.
The EVEX forms (AVX-512F or AVX10.1) narrow sixteen singles and add a mask, with merging only when the destination is memory; VCVTPS2PHX of AVX512-FP16 adds broadcast and an embedded rounding mode. The instruction table of AMD’s Zen 5 guide gives the XMM form one macro-op with a latency of three cycles.
In the optimization guide
What the optimization guide says about VCVTPS2PH, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Zen and Zen+
- Vectors and floating point: Carry-less multiplication with PCLMULQDQ and the half-precision conversions VCVTPH2PS and VCVTPS2PH are microcoded, in AMD’s spreadsheet and in LLVM’s model.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VCVTPS2PH m64, xmm, imm8
VCVTPS2PH_MEMq_XMMdq_IMMb | VEX.128.66.0F3A.W0 1D /r ib | F16C |
VCVTPS2PH xmm, xmm, imm8
VCVTPS2PH_XMMq_XMMdq_IMMb | VEX.128.66.0F3A.W0 1D /r ib | F16C |
VCVTPS2PH m128, ymm, imm8
VCVTPS2PH_MEMdq_YMMqq_IMMb | VEX.256.66.0F3A.W0 1D /r ib | F16C |
VCVTPS2PH xmm, ymm, imm8
VCVTPS2PH_XMMdq_YMMqq_IMMb | VEX.256.66.0F3A.W0 1D /r ib | F16C |
VCVTPS2PH ymm {k}{z}, zmm, imm8, {sae}
VCVTPS2PH_YMMf16_MASKmskw_ZMMf32_IMM8_AVX512 | EVEX.512.66.0F3A.W0 1D /r ib | AVX10.1 or AVX512F |
VCVTPS2PH m256 {k}, zmm, imm8
VCVTPS2PH_MEMf16_MASKmskw_ZMMf32_IMM8_AVX512 | EVEX.512.66.0F3A.W0 1D /r ib | AVX10.1 or AVX512F |
VCVTPS2PH xmm {k}{z}, xmm, imm8
VCVTPS2PH_XMMf16_MASKmskw_XMMf32_IMM8_AVX512 | EVEX.128.66.0F3A.W0 1D /r ib | AVX10.1 or AVX512F + AVX512VL |
VCVTPS2PH m64 {k}, xmm, imm8
VCVTPS2PH_MEMf16_MASKmskw_XMMf32_IMM8_AVX512 | EVEX.128.66.0F3A.W0 1D /r ib | AVX10.1 or AVX512F + AVX512VL |
VCVTPS2PH xmm {k}{z}, ymm, imm8
VCVTPS2PH_XMMf16_MASKmskw_YMMf32_IMM8_AVX512 | EVEX.256.66.0F3A.W0 1D /r ib | AVX10.1 or AVX512F + AVX512VL |
VCVTPS2PH m128 {k}, ymm, imm8
VCVTPS2PH_MEMf16_MASKmskw_YMMf32_IMM8_AVX512 | EVEX.256.66.0F3A.W0 1D /r ib | AVX10.1 or AVX512F + AVX512VL |
Latency and throughput
| Model | m64, xmm, imm8 | xmm, xmm, imm8xmm {k}{z}, xmm, imm8no mask | m128, ymm, imm8 | xmm, ymm, imm8xmm {k}{z}, ymm, imm8no mask | ymm {k}{z}, zmm, imm8, {sae}no mask, with {sae} | ymm {k}{z}, zmm, imm8, {sae}with a mask, zeroing | m256 {k}, zmm, imm8no mask | m256 {k}, zmm, imm8with a mask | xmm {k}{z}, xmm, imm8with a mask, zeroing | m64 {k}, xmm, imm8no mask | m64 {k}, xmm, imm8with a mask | xmm {k}{z}, ymm, imm8with a mask, zeroing | m128 {k}, ymm, imm8no mask | m128 {k}, ymm, imm8with a mask |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Sandy Bridge | 13 / 1p01 | 10 / 1p015 | 13 / 1p01 | 10 / 1p015 | ||||||||||
| Haswell | 5 / 1p15 | 4 / 1p15 | 7 / 1p15 | 6 / 1p15 | ||||||||||
| Broadwell | 5 / 1p1 | 4 / 1p15 | 7 / 1p1 | 6 / 1p15 | ||||||||||
| Skylake | 6 / 1p015 | 5 / 1p015 | 8 / 1p015 | 7 / 1p015 | ||||||||||
| Skylake-SP | 6 / 1p015 | 5 / 1p015 | 8 / 1p015 | 7 / 1p015 | 7 / 1p05 | 7 / 1p05 | 5 / 1p01 | 5 / 1p01 | 5 / 1p015 | 5 / 1p01 | 5 / 1p01 | 7 / 1p015 | 5 / 1p01 | 5 / 1p01 |
| Ice Lake | 6 / 1p015 | 5 / 1p015 | 8 / 1p015 | 7 / 1p015 | 7 / 1p05 | 7 / 1p05 | 5 / 0.5p01 | 5 / 0.5p01 | 5 / 1p015 | 5 / 0.5p01 | 5 / 0.5p01 | 7 / 1p015 | 5 / 0.5p01 | 5 / 0.5p01 |
| Alder Lake | 12 / 0.5p01 | 6 / 1p015 | 12 / 0.5p01 | 8 / 1p015 | ||||||||||
| Sapphire Rapids | 12 / 0.5p01 | 6 / 1p015 | 12 / 0.5p01 | 8 / 1p015 | 8 / 1p05 | 11 / 1p05 | 12 / 1p0 | 16 / 1p0 | 9 / 1p015 | 12 / 0.5p01 | 16 / 0.5p01 | 11 / 1p015 | 12 / 0.5p01 | 16 / 0.5p01 |
| Lunar Lake | 5 / 2V0 V1 | 5 / 2V0 V1 V2 V3 | 5 / 2V0 V1 | 7 / 2V0 V1 V2 V3 | ||||||||||
| Piledriver | 4 / 2FPCVT FPU0 | 8 / 2FPCVT FPSTO FPU0 | 4 / 2FPCVT FPFMA FPU0 | 8 / 2FPCVT FPFMA FPSTO FPU0 | ||||||||||
| Zen, Zen 2 | 100 / 0.25 | 100 / 0.25 | 100 / 0.25 | 100 / 0.25 | ||||||||||
| Zen 3 | 4 / 1FP2 FP3 | 3 / 1FP2 FP3 | 7 / 1FP2 FP3 | 6 / 1FP2 FP3 | ||||||||||
| Zen 4 | 4 / 1FP2 FP3 | 3 / 11FP2 FP3 | 7 / 1FP2 FP3 | 6 / 1FP2 FP3 | 6 / 12FP2 FP3 | 6 / 12FP2 FP3 | 7 / 1FP2 FP3 | 7 / 1FP2 FP3 | 3 / 13FP2 FP3 | 4 / 1FP2 FP3 | 4 / 1FP2 FP3 | 6 / 1FP2 FP3 | 7 / 1FP2 FP3 | 7 / 1FP2 FP3 |
| Jaguar | 4 / 1FPU1 | 3 / 1FPU1 STC | 7 / 2FPA FPM FPU1 | 6 / 2FPA FPM FPU1 STC | ||||||||||
- Zen 4 model: AMD's spreadsheets give reciprocal throughput 0.5 for Zen 4 and Zen 5 (AMD 57647, row 1017; AMD 58455, row 1059).
- Zen 4 model: AMD's spreadsheets give latency 7 for Zen 4 and Zen 5 (AMD 57647, row 1021; AMD 58455, row 78).
- Zen 4 model: AMD's spreadsheets give reciprocal throughput 0.5 for Zen 4 and Zen 5 (AMD 57647, row 1019; AMD 58455, row 75).
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.
A memory destination receives the halves alone. Shown for the zmm form; the xmm and ymm forms work the same on 4 and 8 singles. The EVEX forms write under a mask: where its bit is 0, the element keeps its old value.
Result halves 15 to 0: a15, unchanged (bit 14 of k1 is 0), a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0.
Shown for the zmm form; the xmm and ymm forms work the same on 4 and 8 singles. The EVEX forms write under a mask: where its bit is 0, the element keeps its old value, or zeroes it with {z}.
Result halves 15 to 0: a15, unchanged (bit 14 of k1 is 0), a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
for i in range(VL // 32):
if k1[i]: # 1 without a write mask
a = zmm2.f32[i]
mem.f16[i] = to_f16(a, imm8)
# else: mem.f16[i] is not written
# imm8[1:0]: rn, rd, ru, rz; bit 2: MXCSR.RCRun on AMD Zen 5 (EPYC 9645): 16 cases.
for i in range(VL // 32):
if k1[i]: # 1 without a write mask
a = zmm2.f32[i]
ymm1.f16[i] = to_f16(a, imm8)
elif zeroing:
ymm1.f16[i] = 0
# else: ymm1.f16[i] keeps its value
for i in range(VL // 32, 8):
ymm1.w[i] = 0
# {sae}: no exception flags
# imm8[1:0]: rn, rd, ru, rz; bit 2: MXCSR.RC
# ymm1 is zeroed from bit 128 (xmm) or 256 (ymm) upRun on AMD Zen 5 (EPYC 9645): 37 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VCVTPS2PH xmm/m64, xmm, imm8 VCVTPS2PH xmm/m128, ymm, imm8 | ||
xmm/m64/128 | explicit | write |
xmm, ymm | explicit | read |
imm8 | explicit | read |
VCVTPS2PH xmm/m64 {k}{z}, xmm, imm8 VCVTPS2PH xmm/m128 {k}{z}, ymm, imm8 VCVTPS2PH ymm/m256 {k}{z}, zmm, imm8, {sae} | ||
xmm/m64, xmm/m128, ymm/m256 | explicit | write (masked) |
{k} | explicit | read (write mask) |
xmm, ymm, zmm | 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.
- VEX forms
avx-type-11- EVEX forms
AVX512-E11
Attributes
What else XED records about the forms. How to read.
- All forms
- follows MXCSR
- EVEX forms
- write masking
- EVEX memory forms
- memory fault suppression
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VCVTPS2PH, 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_cvtps_ph
__m128i _mm_cvtps_ph(__m128 a, const int imm) |
|
_mm_mask_cvt_roundps_ph
__m128i _mm_mask_cvt_roundps_ph(__m128i W, __mmask8 U, __m128 A, const int I) |
|
_mm_maskz_cvt_roundps_ph
__m128i _mm_maskz_cvt_roundps_ph(__mmask8 U, __m128 A, const int I) |
|
_mm256_cvtps_ph
__m128i _mm256_cvtps_ph(__m256 a, const int imm) |
|
_mm256_mask_cvt_roundps_ph
__m128i _mm256_mask_cvt_roundps_ph(__m128i W, __mmask8 U, __m256 A, const int I) |
|
_mm256_maskz_cvt_roundps_ph
__m128i _mm256_maskz_cvt_roundps_ph(__mmask8 U, __m256 A, const int I) |
|
_mm512_cvt_roundps_ph
__m256i _mm512_cvt_roundps_ph(__m512 A, const int I) |
|
_mm512_mask_cvt_roundps_ph
__m256i _mm512_mask_cvt_roundps_ph(__m256i U, __mmask16 W, __m512 A, const int I) |
|
_mm512_maskz_cvt_roundps_ph
__m256i _mm512_maskz_cvt_roundps_ph(__mmask16 W, __m512 A, const int I) |
|
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.
More F16C instructions
More AVX10.1 instructions
- VCVTDQ2PS
- VCVTNE2PS2BF16
- VCVTNEPS2BF16
- VCVTPD2DQ
- VCVTPD2PH
- VCVTPD2PS
- VCVTPD2QQ
- VCVTPD2UDQ
- VCVTPD2UQQ
- VCVTPH2DQ
- VCVTPH2PD
- VCVTPH2PS
- VCVTPH2PSX
- VCVTPH2QQ
- VCVTPH2UDQ
- VCVTPH2UQQ
- VCVTPH2UW
- VCVTPH2W
- VCVTPS2DQ
- VCVTPS2PD
- VCVTPS2PHX
- VCVTPS2QQ
- VCVTPS2UDQ
- VCVTPS2UQQ
- VCVTQQ2PD
- VCVTQQ2PH
- VCVTQQ2PS
- VCVTSD2SH
- VCVTSD2SI
- VCVTSD2SS
- VCVTSD2USI
- VCVTSH2SD
- VCVTSH2SI
- VCVTSH2SS
- VCVTSH2USI
- VCVTSI2SD
- VCVTSI2SH
- VCVTSI2SS
- VCVTSS2SD
- VCVTSS2SH
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 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2C, page 5-68 (VCVTPS2PH)
- Intel Advanced Vector Extensions 10.2 Architecture Specification, revision 7.0 (361050-007, April 2026)
- AMD64 Architecture Programmer's Manual, Volume 4: 128-Bit, 256-Bit, and 512-Bit Media Instructions (26568, rev. 3.27, July 2026)
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
- 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.