From a2196ec86f02e7e970e297f09fd73c24f5468624 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Thu, 4 Feb 2021 17:24:53 -0800 Subject: [PATCH] [interpreter] Make popcnt loop up to bitwidth This makes it work for Rep.bitwidth < 32. Otherwise it will keep checking all 32 bits and give the wrong result. --- interpreter/exec/int.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interpreter/exec/int.ml b/interpreter/exec/int.ml index 7236c52831..ec23208d8e 100644 --- a/interpreter/exec/int.ml +++ b/interpreter/exec/int.ml @@ -199,7 +199,7 @@ struct let popcnt x = let rec loop acc i n = - if n = Rep.zero then + if i = 0 then acc else let acc' = if and_ n Rep.one = Rep.one then acc + 1 else acc in