vavgub
Vector Average Unsigned Byte
vavgub vD, vA, vB
Computes (a+b+1)/2 for bytes.
Details
Computes the average of corresponding unsigned bytes in vA and vB using rounding (vA + vB + 1) >> 1, storing the result in vD. This is a vector operation that processes 16 independent byte elements in parallel. No condition flags or status fields are affected.
Pseudocode Operation
for i in 0 to 15 do
vD[8*i:8*i+7] ← ((vA[8*i:8*i+7] + vB[8*i:8*i+7] + 1) >> 1)[7:0]
end for
Programming Note
The vavgub instruction is commonly used for averaging pixel values in image processing tasks. Ensure that the source vectors are properly aligned to avoid performance penalties. This instruction operates at user privilege level and will raise an exception if the vector facility is not enabled (MSR.VEC=0).
Example
vavgub vd, va, vb
Encoding
Binary Layout
4
0
vD
6
vA
11
vB
16
1026
21
Operands
-
vD
Target -
vA
Src A -
vB
Src B