Skip to content

Commit

Permalink
[interpreter] Make popcnt loop up to bitwidth
Browse files Browse the repository at this point in the history
This makes it work for Rep.bitwidth < 32. Otherwise it will keep
checking all 32 bits and give the wrong result.
  • Loading branch information
ngzhian committed Feb 9, 2021
1 parent 9a0269b commit a2196ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion interpreter/exec/int.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2196ec

Please sign in to comment.