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
 
Format VA-form
Opcode 0x10000402
Extension VMX (AltiVec)

Operands

  • vD
    Target
  • vA
    Src A
  • vB
    Src B

Example

vavgub vd, va, vb

Registers Altered

MSR

Related

More in VMX (AltiVec)

Reference

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).