blob: 0c674a664864e42e0dc22ee866ff93c3b4fc6385 [file] [log] [blame] [raw]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="style.css" type="text/css" rel="stylesheet">
<title>HSUBPS—Packed Single-FP Horizontal Subtract </title></head>
<body>
<h1>HSUBPS—Packed Single-FP Horizontal Subtract</h1>
<table>
<tr>
<th>Opcode/Instruction</th>
<th>Op/En</th>
<th>64/32-bit Mode</th>
<th>CPUID Feature Flag</th>
<th>Description</th></tr>
<tr>
<td>
<p>F2 0F 7D /<em>r</em></p>
<p>HSUBPS <em>xmm1,</em> <em>xmm2/m128</em></p></td>
<td>RM</td>
<td>V/V</td>
<td>SSE3</td>
<td>Horizontal subtract packed single-precision floating-point values from <em>xmm2/m128</em> to <em>xmm1</em>.</td></tr>
<tr>
<td>
<p>VEX.NDS.128.F2.0F.WIG 7D /r</p>
<p>VHSUBPS xmm1, xmm2, xmm3/m128</p></td>
<td>RVM</td>
<td>V/V</td>
<td>AVX</td>
<td>Horizontal subtract packed single-precision floating-point values from xmm2 and xmm3/mem.</td></tr>
<tr>
<td>VEX.NDS.256.F2.0F.WIG 7D /r VHSUBPS ymm1, ymm2, ymm3/m256</td>
<td>RVM</td>
<td>V/V</td>
<td>AVX</td>
<td>Horizontal subtract packed single-precision floating-point values from ymm2 and ymm3/mem.</td></tr></table>
<h3>Instruction Operand Encoding</h3>
<table>
<tr>
<td>Op/En</td>
<td>Operand 1</td>
<td>Operand 2</td>
<td>Operand 3</td>
<td>Operand 4</td></tr>
<tr>
<td>RM</td>
<td>ModRM:reg (r, w)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td>
<td>NA</td></tr>
<tr>
<td>RVM</td>
<td>ModRM:reg (w)</td>
<td>VEX.vvvv (r)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td></tr></table>
<h2>Description</h2>
<p>Subtracts the single-precision floating-point value in the second dword of the destination operand from the first dword of the destination operand and stores the result in the first dword of the destination operand.</p>
<p>Subtracts the single-precision floating-point value in the fourth dword of the destination operand from the third dword of the destination operand and stores the result in the second dword of the destination operand.</p>
<p>Subtracts the single-precision floating-point value in the second dword of the source operand from the first dword of the source operand and stores the result in the third dword of the destination operand.</p>
<p>Subtracts the single-precision floating-point value in the fourth dword of the source operand from the third dword of the source operand and stores the result in the fourth dword of the destination operand.</p>
<p>In 64-bit mode, use of the REX.R prefix permits this instruction to access additional registers (XMM8-XMM15).</p>
<p>See Figure 3-21 for HSUBPS; see Figure 3-22 for VHSUBPS.</p>
<svg width="558.09" viewBox="115.440000 294723.000000 372.060000 239.700000" height="359.55">
<text y="294741.682214" x="231.2468" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="105.3559507">HSUBPS xmm1, xmm2/m128</text>
<text y="294762.195814" x="434.4048" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="24.0009">xmm2/</text>
<text y="294766.996314" x="176.6646" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="28.9130842">[127:96]</text>
<text y="294766.996314" x="246.9424" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="24.4649174">[95:64]</text>
<text y="294766.996314" x="314.4451" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="24.4649174">[63:32]</text>
<text y="294766.996314" x="384.1678" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="20.0167506">[31:0]</text>
<text y="294771.796114" x="434.4048" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="20.0087503">m128</text>
<text y="294826.392114" x="434.4048" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="21.7768166">xmm1</text>
<text y="294826.392514" x="176.6646" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="28.9130842">[127:96]</text>
<text y="294826.392514" x="246.9424" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="24.4649174">[95:64]</text>
<text y="294826.392514" x="314.4451" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="24.4649174">[63:32]</text>
<text y="294826.392514" x="384.1678" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="20.0167506">[31:0]</text>
<text y="294885.243914" x="171.7344" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="40.008773">xmm2/m128</text>
<text y="294885.243914" x="239.8121" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="40.008773">xmm2/m128</text>
<text y="294889.863814" x="434.4048" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="32.3052114">RESULT:</text>
<text y="294890.044214" x="304.1747" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="46.481743">xmm1[95:64] -</text>
<text y="294890.044214" x="373.6374" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="42.437955">xmm1[31:0] -</text>
<text y="294894.844314" x="166.644" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="50.525531">[95:64] - xmm2/</text>
<text y="294894.844314" x="236.6818" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="46.481743">[31:0] - xmm2/</text>
<text y="294899.464114" x="434.4048" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="21.7768166">xmm1</text>
<text y="294899.644614" x="304.3747" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="46.081728">xmm1[127:96]</text>
<text y="294899.644614" x="373.8272" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="42.03794">xmm1[63:32]</text>
<text y="294904.444614" x="169.5641" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="44.474395">m128[127:96]</text>
<text y="294904.444614" x="239.6019" style="font-size:7.273000pt" lengthAdjust="spacingAndGlyphs" textLength="40.430607">m128[63:32]</text>
<text y="294929.052814" x="177.2198" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="28.9130842">[127:96]</text>
<text y="294929.052814" x="246.95281489" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="24.4649174">[95:64]</text>
<text y="294929.052814" x="309.9545" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="24.4649174">[63:32]</text>
<text y="294929.052814" x="388.677452" style="font-size:8.000300pt" lengthAdjust="spacingAndGlyphs" textLength="20.0167506">[31:0]</text>
<text y="294954.061009" x="456.4347" style="font-size:6.000100pt" lengthAdjust="spacingAndGlyphs" textLength="26.3464391">OM15996</text>
<rect y="294723.723" x="120.792" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="216.009" width="361.139"></rect>
<rect y="294723.723" x="120.792" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="216.009" width="361.139"></rect>
<path style="stroke:black" d="M259.173000,294777.725000 L259.173000,294788.975000 L135.418000,294788.975000 L135.418000,294858.728000 L191.670000,294858.728000 L191.670000,294864.548000 "></path>
<path style="stroke:black" d="M394.179000,294777.725000 L394.179000,294799.096000 L146.669000,294799.096000 L146.669000,294854.228000 L259.174000,294854.228000 L259.174000,294864.548000 "></path>
<path style="stroke:black" d="M191.107000,294777.725000 L191.107000,294788.975000 "></path>
<path style="stroke:black" d="M326.676000,294777.725000 L326.676000,294799.106000 "></path>
<path style="stroke:black" d="M259.173000,294849.728000 L259.173000,294837.118000 "></path>
<path style="stroke:black" d="M191.670000,294837.122000 L191.670000,294849.733000 L326.675000,294849.733000 L326.675000,294864.413000 "></path>
<path style="stroke:black" d="M326.676000,294837.122000 L326.676000,294845.232000 L394.179000,294845.232000 L394.179000,294864.413000 "></path>
<path style="stroke:black" d="M394.178000,294847.347000 L394.178000,294837.127000 "></path>
<path style="stroke:black" d="M328.716000,294864.413000 L326.676000,294868.493000 L324.636000,294864.413000 L328.716000,294864.413000 "></path>
<path style="stroke:black" d="M396.218000,294864.413000 L394.178000,294868.493000 L392.138000,294864.413000 L396.218000,294864.413000 "></path>
<path style="stroke:black" d="M193.710000,294864.549000 L191.670000,294868.629000 L189.630000,294864.549000 L193.710000,294864.549000 "></path>
<path style="stroke:black" d="M261.213000,294864.549000 L259.173000,294868.629000 L257.133000,294864.549000 L261.213000,294864.549000 "></path>
<rect y="294750.724" x="360.427" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294810.121" x="360.427" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294750.724" x="225.422" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294810.121" x="225.422" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294750.724" x="292.924" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294810.121" x="292.924" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294750.724" x="156.794" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="68.628"></rect>
<rect y="294810.121" x="156.794" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="68.628"></rect>
<rect y="294868.492" x="360.427" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="67.503"></rect>
<rect y="294868.492" x="225.422" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="67.503"></rect>
<rect y="294868.492" x="292.924" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="67.503"></rect>
<rect y="294868.492" x="156.794" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="68.628"></rect>
<rect y="294750.724" x="360.427" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294810.121" x="360.427" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294750.724" x="225.422" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294810.121" x="225.422" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294750.724" x="292.924" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294810.121" x="292.924" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="67.503"></rect>
<rect y="294750.724" x="156.794" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="68.628"></rect>
<rect y="294810.121" x="156.794" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="27.001" width="68.628"></rect>
<rect y="294868.492" x="360.427" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="67.503"></rect>
<rect y="294868.492" x="225.422" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="67.503"></rect>
<rect y="294868.492" x="292.924" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="67.503"></rect>
<rect y="294868.492" x="156.794" style="fill:rgba(0,0,0,0);stroke:rgb(0,0,0);stroke-width:1pt;" height="47.1519999999" width="68.628"></rect></svg>
<h3>Figure 3-21. HSUBPS—Packed Single-FP Horizontal Subtract</h3>
<p>X7</p>
<p>X6</p>
<p>X5</p>
<p>X4</p>
<p>X3</p>
<p>X2</p>
<p>X1</p>
<p>X0</p>
<p>SRC1</p>
<p>Y7</p>
<p>Y6</p>
<p>Y5</p>
<p>Y4</p>
<p>Y3</p>
<p>Y2</p>
<p>Y1</p>
<p>Y0</p>
<p>SRC2</p>
<p>DEST</p>
<p>Y6-Y7</p>
<p>Y4-Y5</p>
<p>X6-X7</p>
<p>X4-X5</p>
<p>Y2-Y3</p>
<p>X2-X3</p>
<p>X0-X1</p>
<h3>Figure 3-22. VHSUBPS operation</h3>
<p>128-bit Legacy SSE version: The second source can be an XMM register or an 128-bit memory location. The desti-nation is not distinct from the first source XMM register and the upper bits (VLMAX-1:128) of the corresponding YMM register destination are unmodified.</p>
<p>VEX.128 encoded version: the first source operand is an XMM register or 128-bit memory location. The destination operand is an XMM register. The upper bits (VLMAX-1:128) of the corresponding YMM register destination are zeroed.</p>
<p>VEX.256 encoded version: The first source operand is a YMM register. The second source operand can be a YMM register or a 256-bit memory location. The destination operand is a YMM register.</p>
<h2>Operation</h2>
<p><strong>HSUBPS (128-bit Legacy SSE version)</strong></p>
<pre>DEST[31:0] ← SRC1[31:0] - SRC1[63:32]
DEST[63:32] ← SRC1[95:64] - SRC1[127:96]
DEST[95:64] ← SRC2[31:0] - SRC2[63:32]
DEST[127:96] ← SRC2[95:64] - SRC2[127:96]
DEST[VLMAX-1:128] (Unmodified)</pre>
<p><strong>VHSUBPS (VEX.128 encoded version)</strong></p>
<pre>DEST[31:0] ← SRC1[31:0] - SRC1[63:32]
DEST[63:32] ← SRC1[95:64] - SRC1[127:96]
DEST[95:64] ← SRC2[31:0] - SRC2[63:32]
DEST[127:96] ← SRC2[95:64] - SRC2[127:96]
DEST[VLMAX-1:128] ← 0</pre>
<p><strong>VHSUBPS (VEX.256 encoded version)</strong></p>
<pre>DEST[31:0] ← SRC1[31:0] - SRC1[63:32]
DEST[63:32] ← SRC1[95:64] - SRC1[127:96]
DEST[95:64] ← SRC2[31:0] - SRC2[63:32]
DEST[127:96] ← SRC2[95:64] - SRC2[127:96]
DEST[159:128] ← SRC1[159:128] - SRC1[191:160]
DEST[191:160] ← SRC1[223:192] - SRC1[255:224]
DEST[223:192] ← SRC2[159:128] - SRC2[191:160]
DEST[255:224] ← SRC2[223:192] - SRC2[255:224]</pre>
<h2>Intel C/C++ Compiler Intrinsic Equivalent</h2>
<p>HSUBPS:</p>
<p>__m128 _mm_hsub_ps(__m128 a, __m128 b);</p>
<p>VHSUBPS:</p>
<p>__m256 _mm256_hsub_ps (__m256 a, __m256 b);</p>
<h2>Exceptions</h2>
<p>When the source operand is a memory operand, the operand must be aligned on a 16-byte boundary or a general-protection exception (#GP) will be generated.</p>
<h2>Numeric Exceptions</h2>
<p>Overflow, Underflow, Invalid, Precision, Denormal.</p>
<h2>Other Exceptions</h2>
<p>See Exceptions Type 2.</p></body></html>