vavguh
Vector Average Unsigned Halfword
Computes (a+b+1)/2 for halfwords.
Details
The Vector Average Unsigned Halfword instruction (vavguh) computes the average of corresponding halfwords from two source vectors, rounding up by adding 1 before shifting right by 1 bit. The result is stored in a destination vector.
Pseudocode Operation
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