vphaddwq
Vector Packed Horizontal Add Word to Quadword
VPHADDWQ xmm1, xmm2/m128
Adds adjacent words to quadwords.
Details
Horizontally adds adjacent groups of four signed 16-bit words from xmm2/m128, accumulating results as 64-bit quadwords in xmm1. Four consecutive words are summed to produce one 64-bit result. This XOP extension instruction does not affect EFLAGS and performs signed arithmetic.
Pseudocode Operation
for i = 0 to 1 {
xmm1[64*i:64*i+63] ← sign_extend(xmm2/m128[16*(4*i):16*(4*i)+15]) + sign_extend(xmm2/m128[16*(4*i+1):16*(4*i+1)+15]) + sign_extend(xmm2/m128[16*(4*i+2):16*(4*i+2)+15]) + sign_extend(xmm2/m128[16*(4*i+3):16*(4*i+3)+15])
}
Example
VPHADDWQ xmm1, xmm2/m128
Encoding
Binary Layout
VEX
+0
opcode
+3
ModRM
+4
Operands
-
dest
128-bit XMM SIMD register -
src
128-bit XMM SIMD register or Memory operand
Reference (AMD APM)
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| 8F RXB.09 0.1111.0.00 C7 /r | VPHADDWQ xmm1, xmm2/mem128 |
Description
Signed Word to Signed Quadword
Adds four successive pairs of 16-bit signed integer values of the source and packs the sign-extended sums to the corresponding quadword of the destination.
There are two operands: VPHADDWQ dest, src
The destination is an XMM register and the source is either an XMM register or a 128-bit memory location. Bits [255:128] of the corresponding YMM register are cleared.
Flags Affected
None None
Exceptions
Exceptions
Mode
Exception Cause of Exception
Real Virt Prot
X Instruction not supported, as indicated by CPUID feature identifier.
X X XOP instructions are only recognized in protected mode.
X CR4.OSXSAVE = 0, indicated by CPUID Fn0000_0001_ECX[OSXSAVE].
X XFEATURE_ENABLED_MASK[2:1] ! = 11b.
Invalid opcode, #UD X XOP.W = 1.
A XOP.vvvv ! = 1111b.
X XOP.L = 1.
X REX, F2, F3, or 66 prefix preceding XOP prefix.
X Lock prefix (F0h) preceding opcode.
Device not available, #NM X CR0.TS = 1.
Stack, #SS X Memory address exceeding stack segment limit or non-canonical.
X Memory address exceeding data segment limit or non-canonical.
General protection, #GP
X Null data segment used to reference memory.
Page fault, #PF X Instruction execution caused a page fault.
Alignment check, #AC X Memory operand not 16-byte aligned when alignment checking enabled.
X — XOP exception
784 [AMDVPHADDWQPublic Use] Instruction Reference