FCVT.W.D
Overview
FCVT.W.D is a RISC-V single-precision floating-point instruction that converts a double-precision floating-point value to a 32-bit signed integer, writing the result into integer register rd.
(Editor's note: the canonical mnemonic FCVT.W.D follows the RISC-V FCVT family convention of "convert from floating-point to integer". The remainder of this article records what the available evidence supports.)
Role in the Zfa Extension
The Zfa extension for RISC-V introduces an instruction, FCVTMOD.W.D, defined similarly to FCVT.W.D, with the following documented differences:
FCVTMOD.W.Dalways rounds towards zero.- Bits 31:0 are taken from the rounded, unbounded two's complement result, then sign-extended to
XLENbits and written to integer registerrd. - Positive infinity, negative infinity, and NaN are converted to zero.
The FCVTMOD.W.D instruction was added to the sail-riscv model as part of the commit that introduced Zfa support (excluding quad-precision), along with several other Zfa instructions such as FLI.[HSD], FMINM.[HSD], FMAXM.[HSD], FROUND.[HSD], FROUNDNX.[HSD], FMVH.X.D, FMVP.D.X, FLEQ.[HSD], and FLTQ.[HSD].
See Also
- FCVTMOD.W.D — derived from
FCVT.W.D; rounds towards zero, treats infinities and NaN as zero, and sign-extends the 32-bit two's complement result toXLENbits.
References
sail-riscvcommitf2d8e1b9(commit9b477812019a78510ebc7f4c7b7efbf378e64a42), which adds Zfa extension support (excluding quad-precision) and contains the definition ofFCVTMOD.W.Drelative toFCVT.W.D.