From 115f34a704e517ffc503355145f86e955438c7a6 Mon Sep 17 00:00:00 2001 From: lkcl Date: Wed, 2 Oct 2019 08:31:32 +0100 Subject: [PATCH] --- simple_v_extension/specification/bitmanip.mdwn | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/simple_v_extension/specification/bitmanip.mdwn b/simple_v_extension/specification/bitmanip.mdwn index 25acef469..d38b4246f 100644 --- a/simple_v_extension/specification/bitmanip.mdwn +++ b/simple_v_extension/specification/bitmanip.mdwn @@ -80,6 +80,15 @@ output instruction pseudoinstruction population-count +Pseudocode: + + unsigned int v; // count the number of bits set in v + unsigned int c; // c accumulates the total bits set in v + for (c = 0; v; c++) + { + v &= v - 1; // clear the least significant bit set + } + ## ffirst - find first bit finds the first bit set as an index. -- 2.30.2