vmaxuh

Vector Maximum Unsigned Halfword

vmaxuh vD, vA, vB

Selects maximum value per halfword (unsigned).

Details

The vmaxuh instruction compares each pair of unsigned halfwords from the source vectors VRA and VRB, and stores the larger value in the corresponding position of the destination vector VRT.

Pseudocode Operation

if MSR.VEC=0 then Vector_Unavailable()
do i = 0 to 7
   src1 ←VSR[VRA+32].hword[i]
   src2 ←VSR[VRB+32].hword[i]

   gt_flag ←EXTZ(src1) > EXTZ(src2)
   VSR[VRT+32].hword[i] ←gt_flag=1 ? src1 : src2
end

Programming Note

The vmaxuh instruction is used to perform element-wise comparisons of unsigned halfwords from two source vectors and store the maximum values in a destination vector. Ensure that the Vector Facility (MSR.VEC) is enabled before using this instruction; otherwise, it will raise an exception. This instruction operates on 16-bit unsigned integers, so ensure proper alignment and data type handling to avoid unexpected results.

Example

vmaxuh vd, va, vb

Encoding

Binary Layout
4
0
vD
6
vA
11
vB
16
68
21
 
Format VA-form
Opcode 0x10000044
Extension VMX (AltiVec)
Registers Altered MSR

Operands

  • vD
    Target
  • vA
    Src A
  • vB
    Src B