27de2900e082aa566225acbd7b7678366d0cd64b
[libreriscv.git] / openpower / sv / fcvt.mdwn
1 [[!tag standards]]
2
3 # SV FP Conversion
4
5 OpenPOWER Scalar ISA requires that FP32 numbers be distributed throughout the bits of the underlying FP64 register such that at any time an FP64 opcode nay be used, without performing any kind of conversion, directly on that FP32 value. Likewise if precision is not important an FP32 opcode may be called on an FP64 value without conversion needed.
6
7 Whilst this is fantastic in that it provides opportunities for speeding up FP64 operations it plays merry hell with SV compacted Vectors of FP32 and FP16 elements, when element width overrides come into play.
8
9 To solve this, the FP values need to be compacted or expanded such that Vector operations do not waste space. The current thinking is that it nay be reasonable to overload `fmv` at different element widths (srcwid != destwid) to perform the necessary conversion, as opposed to just simply doing a straight bitcopy with truncation.
10
11 The result of this has some interesting side-effects when considering what "single precision FP operations" means when elwidth=32. A reasonable interpretation is: the operation is to be performed at FP16 precision yet the result placed in FP32 format, just as how for FP64 single-precision is xarried out at FP32 and placed in FP64.
12
13 see <https://bugs.libre-soc.org/show_bug.cgi?id=564> for discussion.
14
15 # Higher to lower fmv
16
17 Here is the possibility of overflow of the result, as well as rounding. Effectively, this becomes what `frsp` currently does, whilst `frsp` itself has its meaning change from "convert source to single precision" to to "convert source to half of src precision followed by conversion to dest precision" where those two precisions may *or may not* be the same.
18