vavguh
Vector Average Unsigned Halfword
Computes (a+b+1)/2 for halfwords.
Details
Computes the average of corresponding unsigned halfwords in vA and vB using rounding (vA + vB + 1) >> 1, storing the result in vD. This is a vector operation that processes 8 independent halfword elements in parallel. No condition flags or status fields are affected.
Pseudocode Operation
for i in 0 to 7 do
vD[16*i:16*i+15] ← ((vA[16*i:16*i+15] + vB[16*i:16*i+15] + 1) >> 1)[15:0]
end for
Programming Note
The vavguh instruction is used to compute the average of corresponding halfwords from two source vectors, rounding up. Ensure that the Vector Facility (VEC) bit in the Machine State Register (MSR) is set; otherwise, a Vector_Unavailable exception will be raised. This instruction operates on 16-bit unsigned integers and stores the result in the destination vector. Be cautious of overflow when adding the two source halfwords before rounding.
Example
Encoding
Operands
-
vD
Target -
vA
Src A -
vB
Src B