[Libre-soc-isa] [Bug 973] an easy way to shift registers up and down is needed

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sat Oct 29 00:51:26 BST 2022


--- Comment #2 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #1)
>  the easiest way that's achieved
> right now is with twin-predication, setting only source or dest mask.

The problem with using twin-predication, is that we would need special hardware
to recognize those special masks and to optimize it to use slideup/down
hardware (where elements can be grouped into large chunks), rather than general
permutation hardware (where each element is processed independently -- likely
just as slow as svindex).

> source mask with zeros at the front would result in "registers shifted
> right" (down).  destination mask with zeros at the front is "registers
> shifted left" (up).  an instruction which makes it easy to create
> masks from integers is therefore a strong candidate (one that was
> already under consideration in bitmanip, and this is a good use-case
> for it)

well, we already have instructions that would work relatively well for setting
# r5 is shift amount in bits, r32..32+VL is little-endian bigint to shift
srdi r4, r5, 6  # convert from bits to 64-bit words
# bitmanip op would only replace li/sld pair, rest of insns are still needed
li r3, -1
sld r3, r3, r4
# initialize carry in to sign bit, use li r6, 0 for unsigned shift
sv.sradi r6, r32, 63
sv.dsrd/mrr *r16, *r32, r5, r6
# copy back to r32..32+VL shifting right by r4 words
sv.addi/srcmask=r3 *r32, *r16, 0
# final result is in r32..32+VL-r4

for shift left, just set destmask=r3 instead of srcmask=r3. the copy would need
to be preceded by clearing r32..

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

More information about the Libre-SOC-ISA mailing list