(no commit message)
authorlkcl <lkcl@web>
Wed, 26 Apr 2023 15:25:53 +0000 (16:25 +0100)
committerIkiWiki <ikiwiki.info>
Wed, 26 Apr 2023 15:25:53 +0000 (16:25 +0100)
openpower/sv/cookbook/pospopcnt.mdwn [new file with mode: 0644]

diff --git a/openpower/sv/cookbook/pospopcnt.mdwn b/openpower/sv/cookbook/pospopcnt.mdwn
new file mode 100644 (file)
index 0000000..d288971
--- /dev/null
@@ -0,0 +1,21 @@
+<https://bugs.libre-soc.org/show_bug.cgi?id=672>
+
+```
+func count8safe(counts *[8]int, buf []uint8) {
+       for i := range buf {
+               for j := 0; j < 8; j++ {
+                       counts[j] += int(buf[i] >> j & 1)
+               }
+       }
+}
+
+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 ]]