vrfin

Vector Round to Floating-Point Integer Nearest

vrfin vD, vB

Rounds 4 floats to nearest integer.

Details

The vrfin instruction rounds each element of the vector specified by VRB to the nearest integer and stores the result in the vector specified by VRT. The rounding is done towards the nearest integer, with ties rounded away from zero.

Pseudocode Operation

if MSR.VEC=0 then Vector_Unavailable()
do i = 0 to 3
   src ←VSR[VRB+32].word[i]
   VSR[VRT+32].word[i] ← bfp32_ROUND_TO_INTEGER_NEAR(src)
end

Programming Note

The vrfin instruction is commonly used for rounding floating-point numbers in vector operations. Ensure that the Vector Facility (MSR.VEC) is enabled before using this instruction; otherwise, a Vector_Unavailable exception will be raised. Be aware of potential precision loss when rounding to integers, especially with ties. This instruction operates on 32-bit floating-point elements and requires proper alignment for optimal performance.

Example

vrfin vd, vb

Encoding

Binary Layout
4
0
vD
6
0
11
vB
16
522
21
 
Format VX-form
Opcode 0x1000020A
Extension VMX (AltiVec)
Registers Altered MSR

Operands

  • vD
    Target
  • vB
    Source