vrfin
Vector Round to Floating-Point Integer Nearest
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
Encoding
Operands
-
vD
Target -
vB
Source