Skip to content

Commit 7259ea4

Browse files
authored
uses the builtin clz function from base, instead of the custom one (#1418)
1 parent 7fc98eb commit 7259ea4

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

lib/knowledge/bap_knowledge.ml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,9 @@ end
8888

8989
let (lsr) = shift_right_logical
9090

91-
let clz v =
92-
let n = ref@@of_int 64 and x = ref v and y = ref zero in
93-
y := !x lsr 32; if !y <> zero then (n := !n - of_int 32; x := !y);
94-
y := !x lsr 16; if !y <> zero then (n := !n - of_int 16; x := !y);
95-
y := !x lsr 8; if !y <> zero then (n := !n - of_int 8; x := !y);
96-
y := !x lsr 4; if !y <> zero then (n := !n - of_int 4; x := !y);
97-
y := !x lsr 2; if !y <> zero then (n := !n - of_int 2; x := !y);
98-
y := !x lsr 1; if !y <> zero then !n - of_int 2
99-
else !n - !x
100-
[@@inline]
101-
102-
let numbits v = of_int 64 - clz v [@@inline]
91+
let clz v = of_int (clz v) [@@inline]
10392

93+
let numbits v = of_int 63 - clz v [@@inline]
10494

10595
let highest_bit x = numbits x - one
10696
let is_zero ~bit x = x land (one lsl to_int bit) = zero

0 commit comments

Comments
 (0)