1 # Positional popcount SVP64
3 * <https://bugs.libre-soc.org/show_bug.cgi?id=672>
4 * <https://github.com/clausecker/pospop/blob/master/countsse2_amd64.s>
6 Positional popcount in optimised assembler is typically done on SIMD ISAs in
7 around 500 lines. Power ISA thanks to `bpermd` can be much more efficient:
8 with SVP64 even more so. The reference implementation showing the concept
12 // Copyright (c) 2020 Robert Clausecker <fuz@fuz.su>
13 // count8 reference implementation for tests. Do not alter.
14 func count8safe(counts *[8]int, buf []uint8) {
16 for j := 0; j < 8; j++ {
17 counts[j] += int(buf[i] >> j & 1)
22 Array popcount is just standard popcount function on an array of values whereas positional popcount adds up the totals of each bit set to 1 in each bit-position, of an array of input values.
23 <img src="/openpower/sv/cookbook/popcount.svg " alt="pospopcnt" width="70%" />
25 [[!tag svp64_cookbook ]]