# [libre-riscv-dev] [Bug 139] Add LD.X and ST.X? Strided

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Mon Oct 7 09:42:16 BST 2019

```http://bugs.libre-riscv.org/show_bug.cgi?id=139

--- Comment #48 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
https://salsa.debian.org/Kazan-team/pred-copy/blob/master/src/lib.rs

Ok reference lib for clarity.

The purpose of the exercise was to use the approach advocated for twin
predication several months back: compute_index_from_other_index being that
algorithm.  We can get away with using it even in 1 cycle after a contextswitch
because SUBVL is limited to 4, where for VL the cost of a 64 bit long analysis
was just too high.

Mathematically the two indices may be symmetrically derived: if you know one,
you know the other.

Additionally, the two VLs - only one of which is needed if you set the rule
that it is the programmer's responsibility to correctly set the masks - are
also connected through a two way mathrmatically symmetrical formula, involving
POPCOUNT:

Thr reason being that without the destmask skipping, the number of copied
elements will be equal to the number of 1s in the srcmask.

However if any are requested to be skipped, that number drops by the number of
zeros.

Ok, the formula above is not totally accurate, you actually have to go through
the... oh! I know, it's real simple:

DESTVL = compute_index_from_other_index(SRCVL)

that's it. That's the correct formula, accurate under all circumstances.

Therefore we *do not* need all FOUR parameters and pieces of state: only TWO
are needed: either DESTVL and DESTidx, or SRCVL and SRCidx, the other two can
*always* be derived, including after a context switch.

This of course assumes that we have both a destmask and a srcmask, regardless
of their names.

So the question then becomes: why would we ignore this? Is the creation of the
masks too costly? Do they have to be done at runtime? How many cycles would it
cost to set them up?

--
You are receiving this mail because:
You are on the CC list for the bug.
```