[Libre-soc-bugs] [Bug 672] create SVP64 demo / unit test "positional popcount"

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Tue Nov 21 12:03:51 GMT 2023


https://bugs.libre-soc.org/show_bug.cgi?id=672

--- Comment #3 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---

# assume result input all zero already
# count in r3, input address r4, results in r16-r23, temp r8-r16, r32-r63

>    for i := range buf
>        for j := 0; j < 8; j++ 
>            counts[j] += int(buf[i] >> j & 1)

#    use CTR mode
     mtspr CTR, r3
loop:
# clear out 8 temporaries, so that there is no extraneous
     setvli 8
     sv.addi r8, r0, 0
# now copy *up to* the required number, set Rc=1 use later
     setvl. CTR
     sv.lbu/pi *r8, 0(r4) # post-increment r4
# vector of bpermds here, swaps up to 64 at once
     sv.bpermd *r8, *r8
# now do a vectorised 8-bit popcnt, elwidth override to expand to 64 bit
     setvli 8
     sv.popcnt/sw=8 *r8, *r32
# add to accumulation of results, the
     sv.add *r16, *r16, *r32
# and branch back if CR0 ended
     sv.bc/ctr loop

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


More information about the libre-soc-bugs mailing list