xvcvspbf16

Vector Convert Single-Precision to bfloat16 Format

xvcvspbf16 XT,XB

Converts single-precision floating-point values in a vector register to bfloat16 format and stores them in another vector register.

Details

Converts four single-precision floating-point values in the source VSX register XB to bfloat16 (16-bit brain float) format and stores the results in the destination VSX register XT. This VSX instruction performs element-wise truncation and rounding of the single-precision mantissa to 7 bits, preserving the sign and 8-bit exponent. Rounding behavior follows FPSCR settings; the upper 64 bits of XT are packed with converted values.

Pseudocode Operation

for i in 0 to 3 do
  XT[(i % 2)] ← convert_sp_to_bfloat16(XB[i])
end for

Programming Note

This instruction is used to convert four single-precision floating-point values to bfloat16 format. Ensure that the VSX (Vector Scalar Extensions) are enabled in the MSR register, otherwise, a VSX_Unavailable exception will occur. The conversion handles various special cases like NaNs and infinities according to the rounding mode set in FPSCR.RN. Be aware of potential exceptions indicated by flags such as VXSNAN, UX, XX, which can be checked in the FPSCR register.

Example

xvcvspbf16 vs1, vs3

Encoding

Binary Layout
T
17
BX
475
TX
6
 
Format XX2-form
Opcode 0xF011076C
Extension VSX
Registers Altered FPSCR (FX, VXSNAN, OX, UX, XX)

Operands

  • XT
    Target Vector Register
  • XB
    Source Vector Register