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
9 is below, and it adds up the totals of each bit set to 1 in each bit-position,
10 of an array of input alues.
13 // Copyright (c) 2020 Robert Clausecker <fuz@fuz.su>
14 // count8 reference implementation for tests. Do not alter.
15 func count8safe(counts *[8]int, buf []uint8) {
17 for j := 0; j < 8; j++ {
18 counts[j] += int(buf[i] >> j & 1)
24 <img src="/openpower/sv/cookbook/popcount.svg " alt="pospopcnt" width="100%" />
26 [[!tag svp64_cookbook ]]