vrfin

Vector Round to Floating-Point Integer Nearest

vrfin vD, vB

Rounds 4 floats to nearest integer.

Details

Rounds four single-precision floating-point elements in vB to the nearest integer value (using round-to-nearest-even), storing IEEE 754 results in vD. No condition flags are set. This is a Classic VMX (AltiVec) instruction.

Pseudocode Operation

for i in 0 to 3 do
  vD[i] ← round_nearest_even(vB[i])  (IEEE 754 single precision)
endfor

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