ia32-64/x86/vcvtps2ph.html
2025-07-08 02:23:29 -03:00

300 lines
19 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:x86="http://www.felixcloutier.com/x86"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" type="text/css" href="style.css"></link><title>VCVTPS2PH
— Convert Single-Precision FP Value to 16-bit FP Value</title></head><body><header><nav><ul><li><a href='index.html'>Index</a></li><li>December 2023</li></ul></nav></header><h1>VCVTPS2PH
— Convert Single-Precision FP Value to 16-bit FP Value</h1>
<table>
<tr>
<th>Opcode/Instruction</th>
<th>Op/En</th>
<th>64/32 Bit Mode Support</th>
<th>CPUID Feature Flag</th>
<th>Description</th></tr>
<tr>
<td>VEX.128.66.0F3A.W0 1D /r ib VCVTPS2PH xmm1/m64, xmm2, imm8</td>
<td>A</td>
<td>V/V</td>
<td>F16C</td>
<td>Convert four packed single-precision floating-point values in xmm2 to packed half-precision (16-bit) floating-point values in xmm1/m64. Imm8 provides rounding controls.</td></tr>
<tr>
<td>VEX.256.66.0F3A.W0 1D /r ib VCVTPS2PH xmm1/m128, ymm2, imm8</td>
<td>A</td>
<td>V/V</td>
<td>F16C</td>
<td>Convert eight packed single-precision floating-point values in ymm2 to packed half-precision (16-bit) floating-point values in xmm1/m128. Imm8 provides rounding controls.</td></tr>
<tr>
<td>EVEX.128.66.0F3A.W0 1D /r ib VCVTPS2PH xmm1/m64 {k1}{z}, xmm2, imm8</td>
<td>B</td>
<td>V/V</td>
<td>AVX512VL AVX512F</td>
<td>Convert four packed single-precision floating-point values in xmm2 to packed half-precision (16-bit) floating-point values in xmm1/m64. Imm8 provides rounding controls.</td></tr>
<tr>
<td>EVEX.256.66.0F3A.W0 1D /r ib VCVTPS2PH xmm1/m128 {k1}{z}, ymm2, imm8</td>
<td>B</td>
<td>V/V</td>
<td>AVX512VL AVX512F</td>
<td>Convert eight packed single-precision floating-point values in ymm2 to packed half-precision (16-bit) floating-point values in xmm1/m128. Imm8 provides rounding controls.</td></tr>
<tr>
<td>EVEX.512.66.0F3A.W0 1D /r ib VCVTPS2PH ymm1/m256 {k1}{z}, zmm2{sae}, imm8</td>
<td>B</td>
<td>V/V</td>
<td>AVX512F</td>
<td>Convert sixteen packed single-precision floating-point values in zmm2 to packed half-precision (16-bit) floating-point values in ymm1/m256. Imm8 provides rounding controls.</td></tr></table>
<h2 id="instruction-operand-encoding">Instruction Operand Encoding<a class="anchor" href="#instruction-operand-encoding">
</a></h2>
<table>
<tr>
<th>Op/En</th>
<th>Tuple Type</th>
<th>Operand 1</th>
<th>Operand 2</th>
<th>Operand 3</th>
<th>Operand 4</th></tr>
<tr>
<td>A</td>
<td>N/A</td>
<td>ModRM:r/m (w)</td>
<td>ModRM:reg (r)</td>
<td>imm8</td>
<td>N/A</td></tr>
<tr>
<td>B</td>
<td>Half Mem</td>
<td>ModRM:r/m (w)</td>
<td>ModRM:reg (r)</td>
<td>imm8</td>
<td>N/A</td></tr></table>
<h3 id="description">Description<a class="anchor" href="#description">
</a></h3>
<p>Convert packed single-precision floating values in the source operand to half-precision (16-bit) floating-point values and store to the destination operand. The rounding mode is specified using the immediate field (imm8).</p>
<p>Underflow results (i.e., tiny results) are converted to denormals. MXCSR.FTZ is ignored. If a source element is denormal relative to the input format with DM masked and at least one of PM or UM unmasked; a SIMD exception will be raised with DE, UE and PE set.</p>
<figure id="fig-5-7">
<svg style="width: 475.77604799999995pt; height: 167.471976pt" viewBox="101.24000000000001 0.0 401.48004 144.55998000000002">
<g xmlns="http://www.w3.org/2000/svg" style="fill: none; stroke: none">
<rect height="138.54" style="fill: rgb(0%, 0%, 0%)" width="0.48" x="103.74000000000001" y="0.47998000000001184"></rect>
<rect height="138.54" style="fill: rgb(0%, 0%, 0%)" width="0.48004" x="499.74" y="0.47998000000001184"></rect>
<rect height="0.47998" style="fill: rgb(0%, 0%, 0%)" width="396.48" x="103.74000000000001" y="0.0"></rect>
<rect height="0.48001000000000005" style="fill: rgb(0%, 0%, 0%)" width="396.48" x="103.74000000000001" y="139.07997000000003"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="40.02" x="391.92" y="119.87998000000005"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="39.96" x="351.96" y="119.87998000000005"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="39.96" x="351.96" y="119.87998000000005"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="40.02" x="311.94" y="119.87998000000005"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="40.02" x="311.94" y="119.87998000000005"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="39.96" x="271.98" y="119.87998000000005"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="39.96" x="271.98" y="119.87998000000005"></rect>
<rect height="10.32" style="fill: rgb(75%, 75%, 75%)" width="79.98" x="192.0" y="119.87998000000005"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="79.98" x="192.0" y="119.87998000000005"></rect>
<rect height="10.32" style="fill: rgb(75%, 75%, 75%)" width="79.98" x="112.02" y="119.87998000000005"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="79.98" x="112.02" y="119.87998000000005"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="79.98" x="351.96" y="37.01998000000003"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="79.98" x="351.96" y="37.01998000000003"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="79.98" x="271.98" y="37.01998000000003"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="79.98" x="271.98" y="37.01998000000003"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="79.98" x="192.0" y="37.01998000000003"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="79.98" x="192.0" y="37.01998000000003"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="79.98" x="112.02" y="37.01998000000003"></rect>
<rect height="10.32" style="stroke: rgb(0%, 0%, 0%)" width="79.98" x="112.02" y="37.01998000000003"></rect>
<path d="M 391.92 47.339980000000025 L 391.92 57.71998000000002 L 411.96000000000004 57.71998000000002 L 411.96000000000004 119.69998000000004" style="fill-rule: nonzero; stroke: rgb(0%, 0%, 0%)"></path>
<path d="M 311.94 47.339980000000025 L 311.94 68.09998000000002 L 371.94 68.09998000000002 L 371.94 119.87998000000005" style="fill-rule: nonzero; stroke: rgb(0%, 0%, 0%)"></path>
<path d="M 231.95999999999998 47.339980000000025 L 231.95999999999998 78.41998000000004 L 331.97999999999996 78.41998000000004 L 331.97999999999996 119.87998000000005" style="fill-rule: nonzero; stroke: rgb(0%, 0%, 0%)"></path>
<path d="M 151.97999999999996 47.339980000000025 L 151.97999999999996 88.79998000000003 L 291.9599999999999 88.79998000000003 L 291.9599999999999 119.87998000000005" style="fill-rule: nonzero; stroke: rgb(0%, 0%, 0%)"></path>
<rect height="10.38" style="fill: rgb(100%, 100%, 100%)" width="28.5" x="397.68" y="60.29998000000003"></rect>
<rect height="10.38" style="fill: rgb(100%, 100%, 100%)" width="28.5" x="138.24" y="57.71998000000002"></rect>
<rect height="10.32" style="fill: rgb(100%, 100%, 100%)" width="28.44" x="297.72" y="55.13998000000004"></rect>
<rect height="10.38" style="fill: rgb(100%, 100%, 100%)" width="28.44" x="217.74" y="57.71998000000002"></rect>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="127.51074407426213" x="194.33875835000006" y="24.896842852714656">VCVTPS2PHxmm1/mem64,xmm2, imm8</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="11.284996184262312" x="114.35893045000006" y="35.21694205271467">127</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="26.25290886426197" x="175.5925832800004" y="35.21694205271467">96 95</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="26.669505464261988" x="255.15648651000043" y="35.21694205271467">64 63</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="26.669505464261647" x="335.13698634000076" y="35.21694205271467">32 31</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310678pt; fill: #000" textLength="3.786929314262295" x="418.4798238900008" y="35.21694205271466">0</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="12.967508904262331" x="145.56" y="45.59710605271471">VS3</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="12.967508904262303" x="225.54" y="45.59710605271471">VS2</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="12.967508904262331" x="305.52" y="45.59710605271471">VS1</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="12.967508904262331" x="385.5" y="45.59710605271471">VS0</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="17.946510204262268" x="444.2396043000001" y="45.59710605271468">xmm2</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="21.87061548713126" x="300.12" y="63.71710605271468">convert</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="21.871287417131157" x="140.58" y="66.2971060527147">convert</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310692pt; fill: #000" textLength="21.87061548713112" x="220.14000000000001" y="66.2971060527147">convert</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="21.93041725713124" x="400.08" y="68.87710605271471">convert</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="11.284996184262312" x="114.35815147999989" y="118.0771060527147">127</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="7.565863634262286" x="175.59180431000024" y="118.0771060527147">96</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="7.506061864262307" x="194.3386513099999" y="118.0771060527147">95</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="26.669505464261988" x="255.15570754000026" y="118.0771060527147">64 63</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="21.71469364426207" x="300.1306701600002" y="118.0771060527147">48 47</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="21.65489187426209" x="340.1508209600002" y="118.0771060527147">32 31</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="47.109616064262354" x="380.11116999000023" y="118.0771060527147">16 15 0</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="12.966165044262311" x="285.54" y="128.4571060527147">VH3</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="12.906363274262333" x="325.56" y="128.4571060527147">VH2</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="12.966165044262311" x="365.52" y="128.4571060527147">VH1</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="12.906363274262333" x="405.54" y="128.4571060527147">VH0</text>
<text lengthAdjust="spacingAndGlyphs" style="font-size: 7.601102724310664pt; fill: #000" textLength="42.11784809426217" x="444.2396043000001" y="128.45753325271468">xmm1/mem64</text></g></svg>
<figcaption><a href='vcvtps2ph.html#fig-5-7'>Figure 5-7</a>. VCVTPS2PH (128-bit Version)</figcaption></figure>
<p>The immediate byte defines several bit fields that control rounding operation. The effect and encoding of the RC field are listed in <a href='vcvtps2ph.html#tbl-5-13'>Table 5-13</a>.</p>
<figure id="tbl-5-13">
<table>
<tr>
<th>Bits</th>
<th>Field Name/value</th>
<th>Description</th>
<th>Comment</th></tr>
<tr>
<td rowspan="4">Imm[1:0]</td>
<td>RC=00B</td>
<td>Round to nearest even</td>
<td rowspan="4">If Imm[2] = 0</td></tr>
<tr>
<td>RC=01B</td>
<td>Round down</td></tr>
<tr>
<td>RC=10B</td>
<td>Round up</td></tr>
<tr>
<td>RC=11B</td>
<td>Truncate</td></tr>
<tr>
<td rowspan="2">Imm[2]</td>
<td>MS1=0</td>
<td>Use imm[1:0] for rounding</td>
<td>Ignore MXCSR.RC</td></tr>
<tr>
<td>MS1=1</td>
<td>Use MXCSR.RC for rounding</td>
<td></td></tr>
<tr>
<td>Imm[7:3]</td>
<td>Ignored</td>
<td>Ignored by processor</td>
<td></td></tr></table>
<figcaption><a href='vcvtps2ph.html#tbl-5-13'>Table 5-13</a>. Immediate Byte Encoding for 16-bit Floating-Point Conversion Instructions</figcaption></figure>
<p>VEX.128 version: The source operand is a XMM register. The destination operand is a XMM register or 64-bit memory location. If the destination operand is a register then the upper bits (MAXVL-1:64) of corresponding register are zeroed.</p>
<p>VEX.256 version: The source operand is a YMM register. The destination operand is a XMM register or 128-bit memory location. If the destination operand is a register, the upper bits (MAXVL-1:128) of the corresponding destination register are zeroed.</p>
<p>Note: VEX.vvvv and EVEX.vvvv are reserved (must be 1111b).</p>
<p>EVEX encoded versions: The source operand is a ZMM/YMM/XMM register. The destination operand is a YMM/XMM/XMM (low 64-bits) register or a 256/128/64-bit memory location, conditionally updated with writemask k1. Bits (MAXVL-1:256/128/64) of the corresponding destination register are zeroed.</p>
<h3 id="operation">Operation<a class="anchor" href="#operation">
</a></h3>
<pre>vCvt_s2h(SRC1[31:0])
{
IF Imm[2] = 0
THEN ; using Imm[1:0] for rounding control, see <a href='vcvtps2ph.html#tbl-5-13'>Table 5-13</a>
RETURN Cvt_Single_Precision_To_Half_Precision_FP_Imm(SRC1[31:0]);
ELSE ; using MXCSR.RC for rounding control
RETURN Cvt_Single_Precision_To_Half_Precision_FP_Mxcsr(SRC1[31:0]);
FI;
}
</pre>
<h4 id="vcvtps2ph--evex-encoded-versions--when-dest-is-a-register">VCVTPS2PH (EVEX Encoded Versions) When DEST is a Register<a class="anchor" href="#vcvtps2ph--evex-encoded-versions--when-dest-is-a-register">
</a></h4>
<pre>(KL, VL) = (4, 128), (8, 256), (16, 512)
FOR j := 0 TO KL-1
i := j * 16
k := j * 32
IF k1[j] OR *no writemask*
THEN DEST[i+15:i] :=
vCvt_s2h(SRC[k+31:k])
ELSE
IF *merging-masking*
; merging-masking
THEN *DEST[i+15:i] remains unchanged*
ELSE
; zeroing-masking
DEST[i+15:i] := 0
FI
FI;
ENDFOR
DEST[MAXVL-1:VL/2] := 0
</pre>
<h4 id="vcvtps2ph--evex-encoded-versions--when-dest-is-memory">VCVTPS2PH (EVEX Encoded Versions) When DEST is Memory<a class="anchor" href="#vcvtps2ph--evex-encoded-versions--when-dest-is-memory">
</a></h4>
<pre>(KL, VL) = (4, 128), (8, 256), (16, 512)
FOR j := 0 TO KL-1
i := j * 16
k := j * 32
IF k1[j] OR *no writemask*
THEN DEST[i+15:i] :=
vCvt_s2h(SRC[k+31:k])
ELSE
*DEST[i+15:i] remains unchanged*
; merging-masking
FI;
ENDFOR
</pre>
<h4 id="vcvtps2ph--vex-256-encoded-version-">VCVTPS2PH (VEX.256 Encoded Version)<a class="anchor" href="#vcvtps2ph--vex-256-encoded-version-">
</a></h4>
<pre>DEST[15:0] := vCvt_s2h(SRC1[31:0]);
DEST[31:16] := vCvt_s2h(SRC1[63:32]);
DEST[47:32] := vCvt_s2h(SRC1[95:64]);
DEST[63:48] := vCvt_s2h(SRC1[127:96]);
DEST[79:64] := vCvt_s2h(SRC1[159:128]);
DEST[95:80] := vCvt_s2h(SRC1[191:160]);
DEST[111:96] := vCvt_s2h(SRC1[223:192]);
DEST[127:112] := vCvt_s2h(SRC1[255:224]);
DEST[MAXVL-1:128] := 0
</pre>
<h4 id="vcvtps2ph--vex-128-encoded-version-">VCVTPS2PH (VEX.128 Encoded Version)<a class="anchor" href="#vcvtps2ph--vex-128-encoded-version-">
</a></h4>
<pre>DEST[15:0] := vCvt_s2h(SRC1[31:0]);
DEST[31:16] := vCvt_s2h(SRC1[63:32]);
DEST[47:32] := vCvt_s2h(SRC1[95:64]);
DEST[63:48] := vCvt_s2h(SRC1[127:96]);
DEST[MAXVL-1:64] := 0
</pre>
<h3 id="flags-affected">Flags Affected<a class="anchor" href="#flags-affected">
</a></h3>
<p>None.</p>
<h3 id="intel-c-c++-compiler-intrinsic-equivalent">Intel C/C++ Compiler Intrinsic Equivalent<a class="anchor" href="#intel-c-c++-compiler-intrinsic-equivalent">
</a></h3>
<pre>VCVTPS2PH __m256i _mm512_cvtps_ph(__m512 a);
</pre>
<pre>VCVTPS2PH __m256i _mm512_mask_cvtps_ph(__m256i s, __mmask16 k,__m512 a);
</pre>
<pre>VCVTPS2PH __m256i _mm512_maskz_cvtps_ph(__mmask16 k,__m512 a);
</pre>
<pre>VCVTPS2PH __m256i _mm512_cvt_roundps_ph(__m512 a, const int imm);
</pre>
<pre>VCVTPS2PH __m256i _mm512_mask_cvt_roundps_ph(__m256i s, __mmask16 k,__m512 a, const int imm);
</pre>
<pre>VCVTPS2PH __m256i _mm512_maskz_cvt_roundps_ph(__mmask16 k,__m512 a, const int imm);
</pre>
<pre>VCVTPS2PH __m128i _mm256_mask_cvtps_ph(__m128i s, __mmask8 k,__m256 a);
</pre>
<pre>VCVTPS2PH __m128i _mm256_maskz_cvtps_ph(__mmask8 k,__m256 a);
</pre>
<pre>VCVTPS2PH __m128i _mm_mask_cvtps_ph(__m128i s, __mmask8 k,__m128 a);
</pre>
<pre>VCVTPS2PH __m128i _mm_maskz_cvtps_ph(__mmask8 k,__m128 a);
</pre>
<pre>VCVTPS2PH __m128i _mm_cvtps_ph ( __m128 m1, const int imm);
</pre>
<pre>VCVTPS2PH __m128i _mm256_cvtps_ph(__m256 m1, const int imm);
</pre>
<h3 class="exceptions" id="simd-floating-point-exceptions">SIMD Floating-Point Exceptions<a class="anchor" href="#simd-floating-point-exceptions">
</a></h3>
<p>Invalid, Underflow, Overflow, Precision, Denormal (if MXCSR.DAZ=0).</p>
<h3 class="exceptions" id="other-exceptions">Other Exceptions<a class="anchor" href="#other-exceptions">
</a></h3>
<p>VEX-encoded instructions, see <span class="not-imported">Table 2-26</span>, “Type 11 Class Exception Conditions” (do not report #AC);</p>
<p>EVEX-encoded instructions, see <span class="not-imported">Table 2-60</span>, “Type E11 Class Exception Conditions.”</p>
<p>Additionally:</p>
<table>
<tr>
<td>#UD</td>
<td>If VEX.W=1.</td></tr>
<tr>
<td>#UD</td>
<td>If VEX.vvvv != 1111B or EVEX.vvvv != 1111B.</td></tr></table><footer><p>
This UNOFFICIAL, mechanically-separated, non-verified reference is provided for convenience, but it may be
inc<span style="opacity: 0.2">omp</span>lete or b<sub>r</sub>oke<sub>n</sub> in various obvious or non-obvious
ways. Refer to <a href="https://software.intel.com/en-us/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4">Intel® 64 and IA-32 Architectures Software Developers Manual</a> for anything serious.
</p></footer></body></html>