From 0e0093bf40580546fb5487e12e1c8689ba819369 Mon Sep 17 00:00:00 2001 From: lkcl Date: Wed, 26 Apr 2023 16:25:53 +0100 Subject: [PATCH] --- openpower/sv/cookbook/pospopcnt.mdwn | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 openpower/sv/cookbook/pospopcnt.mdwn diff --git a/openpower/sv/cookbook/pospopcnt.mdwn b/openpower/sv/cookbook/pospopcnt.mdwn new file mode 100644 index 000000000..d28897169 --- /dev/null +++ b/openpower/sv/cookbook/pospopcnt.mdwn @@ -0,0 +1,21 @@ + + +``` +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 ]] -- 2.30.2