vphaddwd

Vector Packed Horizontal Add Word to Doubleword

VPHADDWD xmm1, xmm2/m128

Adds adjacent words to doublewords.

Details

Horizontally adds adjacent pairs of signed 16-bit words from xmm2/m128, accumulating results as 32-bit doublewords in xmm1. Each pair of words produces one 32-bit doubleword result; the operation doubles the data width. This XOP extension instruction does not affect EFLAGS and performs signed arithmetic.

Pseudocode Operation

for i = 0 to 3 {
  xmm1[32*i:32*i+31] ← sign_extend(xmm2/m128[16*(2*i):16*(2*i)+15]) + sign_extend(xmm2/m128[16*(2*i+1):16*(2*i+1)+15])
}

Example

VPHADDWD xmm1, xmm2/m128

Encoding

Binary Layout
VEX
+0
opcode
+3
ModRM
+4
 
Format XOP
Opcode XOP.128.09.W0 C6 /r
Extension XOP

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 C6 /r VPHADDWD xmm1, xmm2/mem128

Description

Signed Word to Signed Doubleword Adds four adjacent pairs of 16-bit signed integer values of the source and packs the sign-extended sums to the corresponding doubleword of the destination. There are two operands: VPHADDWD 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 782 [AMDVPHADDWDPublic Use] Instruction Reference