-<https://bugs.libre-soc.org/show_bug.cgi?id=672>
+# Positional popcount SVP64
+
+* <https://bugs.libre-soc.org/show_bug.cgi?id=672>
+* <https://github.com/clausecker/pospop/blob/master/countsse2_amd64.s>
+
+Positional popcount in optimised assembler is typically done on SIMD ISAs in
+around 500 lines. Power ISA thanks to `bpermd` can be much more efficient:
+with SVP64 even more so. The reference implementation showing the concept
+is below, and it adds up the totals of each bit set to 1 in each bit-position,
+of an array of input alues.
```
+// Copyright (c) 2020 Robert Clausecker <fuz@fuz.su>
+// count8 reference implementation for tests. Do not alter.
func count8safe(counts *[8]int, buf []uint8) {
for i := range buf {
for j := 0; j < 8; j++ {
}
}
}
-
-func count16safe(counts *[16]int, buf []uint16) {
- for i := range buf {
- for j := 0; j < 16; j++ {
- counts[j] += int(buf[i] >> j & 1)
- }
- }
-}
```
[[!tag svp64_cookbook ]]