vavgub
Vector Average Unsigned Byte
vavgub vD, vA, vB
Computes (a+b+1)/2 for bytes.
Encoding
Binary Layout
4
0:5
vD
6:10
vA
11:15
vB
16:20
1026
21:31
Operands
-
vD
Target -
vA
Src A -
vB
Src B
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
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.
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).