vrfin
Vector Round to Floating-Point Integer Nearest
vrfin vD, vB
Rounds 4 floats to nearest integer.
Encoding
Binary Layout
4
0:5
vD
6:10
0
11:15
vB
16:20
522
21:31
Operands
-
vD
Target -
vB
Source
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
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.
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.