xvcvspbf16
Vector Convert Single-Precision to bfloat16 Format
Converts single-precision floating-point values in a vector register to bfloat16 format and stores them in another vector register.
Details
The xvcvspbf16 instruction converts four single-precision floating-point values from the source vector register VSR[XB] to bfloat16 format and stores them in the target vector register VSR[XT]. Each conversion handles NaNs, infinities, zeros, and normal numbers according to the rounding mode specified in FPSCR.RN.
Pseudocode Operation
if MSR.VSX=0 then VSX_Unavailable()
do i = 0 to 3
reset_flags()
src ← bfp_CONVERT_FROM_BFP32(VSR[32×BX+B].word[i])
rnd ← bfp_ROUND_TO_BFLOAT16(FPSCR.RN,src)
result.word[i].hword[0] ← 0x0000
result.word[i].hword[1] ← bfloat16_CONVERT_FROM_BFP(rnd)
if vxsnan_flag=1 then SetFX(FPSCR.VXSNAN)
if ux_flag=1 then SetFX(FPSCR.UX)
if xx_flag=1 then SetFX(FPSCR.XX)
ex_flag ← ex_flag | (FPSCR.VE & vxsnan_flag) | (FPSCR.OE & ox_flag) | (FPSCR.UE & ux_flag) | (FPSCR.XE & xx_flag)
end
if ex_flag=0 then VSR[32×TX+T] ← result
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
Encoding
Operands
-
XT
Target Vector Register -
XB
Source Vector Register