[libre-riscv-dev] fp special functions

Luke Kenneth Casson Leighton lkcl at lkcl.net
Mon Aug 5 00:02:29 BST 2019

crowd-funded eco-conscious hardware: https://www.crowdsupply.com/eoma68

On Sun, Aug 4, 2019 at 11:48 PM Jacob Lifshay <programmerjake at gmail.com> wrote:

> > if however, the following special conditions are met:
> >
> > * SV's Sub-Vector Len is set to 4 AND
> > * SV element width is set to 32-bit for the TARGET register AND
> > * SV element width is set to 32-bit for the SOURCE register

> It should work just fine with the scalar version to be convert f32 to
> normalized u8 with saturation. with the semantics that a 4xu8 vector is
> packed in a 32-bit value, we should have no problems.


> We will need to use
> this trick with sRGB conversions, however. note that dest element width
> would be 8-bits in both cases. if the in-memory byte order is something
> other than rgba, then we can just do a swizzle operation.

ok.  dang, have to make a note of this, somewhere.

> > it is an extremely unusual use of SV: normally the scalar opcodes
> > exist independently of their "vectorised equivalents".  however it
> > makes absolutely no sense in this case, because 1xFP32 ARGB to 1xINT32
> > ARGB8888 is nonsense (impossible).
> >
> yeah, but 1x f32 to 1x norm-u8 is quite reasonable.

it's usually independent?  i thought there was some
inter-relationship.  have to make sure that case can be covered, then.

> > i believe there may be many other candidate instruction opportunities
> > that could benefit from this trick.  SLERP for example requires
> > Quaternions, to specify the points, *and* a 3rd argument (t).
> > https://en.wikipedia.org/wiki/Slerp
> as far as I know, slerp doesn't require any operations that are specific to
> quaternions, all the operations are done on scalars, are standard scalar
> and 4d vector multiplications, or are 4d vector dot-products. therefore, I
> don't think we need any special quaternion instructions to implement slerp.


i haven't researched it fully, my interpretation of that c++ source
code would be that the Quaternion data structure would be simply to
store the vector args 1 and 2.

apologies, yes: no quarternions needed, just vectors.


More information about the libre-riscv-dev mailing list