(no commit message)
[libreriscv.git] / openpower / sv / cookbook / pospopcnt.mdwn
1 <https://bugs.libre-soc.org/show_bug.cgi?id=672>
2
3 ```
4 func count8safe(counts *[8]int, buf []uint8) {
5 for i := range buf {
6 for j := 0; j < 8; j++ {
7 counts[j] += int(buf[i] >> j & 1)
8 }
9 }
10 }
11
12 func count16safe(counts *[16]int, buf []uint16) {
13 for i := range buf {
14 for j := 0; j < 16; j++ {
15 counts[j] += int(buf[i] >> j & 1)
16 }
17 }
18 }
19 ```
20
21 [[!tag svp64_cookbook ]]