vsubph
Subtract Packed FP16 Values
VSUBPH zmm1 {k1}, zmm2, zmm3/m512
Subtracts half-precision floating-point values.
Details
Subtracts 32 pairs of half-precision (FP16) floating-point values (zmm3/m512 from zmm2), storing the result in zmm1 with optional write masking via k1. The operation follows IEEE 754 semantics for FP16 arithmetic with configurable rounding modes from MXCSR. Requires AVX-512-FP16 extension. Exception behavior depends on MXCSR exception mask and denormal handling.
Pseudocode Operation
for i ← 0 to 31 do
if (k1[i] or no_mask) then
zmm1[16*i+15:16*i] ← FP16_SUB(zmm2[16*i+15:16*i], zmm3[16*i+15:16*i]);
else if (zeroing_mask)
zmm1[16*i+15:16*i] ← 0;
endfor;
// MXCSR exception flags updated per result
Example
VSUBPH zmm1, zmm2, zmm3/m512
Encoding
Binary Layout
EVEX
+0
5C
+4
Operands
-
dest
512-bit ZMM AVX-512 register -
src1
512-bit ZMM AVX-512 register -
src2
512-bit ZMM AVX-512 register or Memory operand
Reference (Intel® SDM)
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| EVEX.128.NP.MAP5.W0 5C /r | VSUBPH xmm1{k1}{z}, xmm2, xmm3/m128/m16bcst | A | V/V | (AVX512_FP16 AND AVX512VL) OR AVX10.1 | Subtract packed FP16 values from xmm3/m128/m16bcst to xmm2, and store the result in xmm1 subject to writemask k1. |
| EVEX.256.NP.MAP5.W0 5C /r | VSUBPH ymm1{k1}{z}, ymm2, ymm3/m256/m16bcst | A | V/V | (AVX512_FP16 AND AVX512VL) OR AVX10.11 | Subtract packed FP16 values from ymm3/m256/m16bcst to ymm2, and store the result in ymm1 subject to writemask k1. |
| EVEX.512.NP.MAP5.W0 5C /r | VSUBPH zmm1{k1}{z}, zmm2, zmm3/m512/m16bcst {er} | A | V/V | AVX512_FP16 OR AVX10.11 | Subtract packed FP16 values from zmm3/m512/m16bcst to zmm2, and store the result in zmm1 subject to writemask k1. |
Instruction Operand Encoding
| Op/En | Tuple Type | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
|---|---|---|---|---|---|
| A | Full | ModRM:reg (w) | VEX.vvvv (r) | ModRM:r/m (r) | N/A |
Description
This instruction subtracts packed FP16 values from second source operand from the corresponding elements in the first source operand, storing the packed FP16 result in the destination operand. The destination elements are updated according to the writemask.
Operation
VSUBPH (EVEX encoded versions) when src2 operand is a register VL = 128, 256 or 512 KL := VL/16 IF (VL = 512) AND (EVEX.b = 1): SET_RM(EVEX.RC) ELSE SET_RM(MXCSR.RC) FOR j := 0 TO KL-1: IF k1[j] OR *no writemask*: DEST.fp16[j] := SRC1.fp16[j] - SRC2.fp16[j] ELSE IF *zeroing*: DEST.fp16[j] := 0 // else dest.fp16[j] remains unchanged DEST[MAXVL-1:VL] := 0 VSUBPH—Subtract Packed FP16 Values Vol. 2C 5-768 VSUBPH (EVEX encoded versions) when src2 operand is a memory source VL = 128, 256 or 512 KL := VL/16 FOR j := 0 TO KL-1: IF k1[j] OR *no writemask*: IF EVEX.b = 1: DEST.fp16[j] := SRC1.fp16[j] - SRC2.fp16[0] ELSE: DEST.fp16[j] := SRC1.fp16[j] - SRC2.fp16[j] ELSE IF *zeroing*: DEST.fp16[j] := 0 // else dest.fp16[j] remains unchanged DEST[MAXVL-1:VL] := 0
Intel C/C++ Compiler Intrinsic Equivalent
VSUBPH __m128h _mm_mask_sub_ph (__m128h src, __mmask8 k, __m128h a, __m128h b); VSUBPH __m128h _mm_maskz_sub_ph (__mmask8 k, __m128h a, __m128h b); VSUBPH __m128h _mm_sub_ph (__m128h a, __m128h b); VSUBPH __m256h _mm256_mask_sub_ph (__m256h src, __mmask16 k, __m256h a, __m256h b); VSUBPH __m256h _mm256_maskz_sub_ph (__mmask16 k, __m256h a, __m256h b); VSUBPH __m256h _mm256_sub_ph (__m256h a, __m256h b); VSUBPH __m512h _mm512_mask_sub_ph (__m512h src, __mmask32 k, __m512h a, __m512h b); VSUBPH __m512h _mm512_maskz_sub_ph (__mmask32 k, __m512h a, __m512h b); VSUBPH __m512h _mm512_sub_ph (__m512h a, __m512h b); VSUBPH __m512h _mm512_mask_sub_round_ph (__m512h src, __mmask32 k, __m512h a, __m512h b, int rounding); VSUBPH __m512h _mm512_maskz_sub_round_ph (__mmask32 k, __m512h a, __m512h b, int rounding); VSUBPH __m512h _mm512_sub_round_ph (__m512h a, __m512h b, int rounding);
Exceptions
SIMD Floating-Point Exceptions
Invalid, Underflow, Overflow, Precision, Denormal.
Other Exceptions
EVEX-encoded instruction, see Table 2-48, “Type E2 Class Exception Conditions.”
VSUBPH—Subtract Packed FP16 Values Vol. 2C 5-769