perf(cc): more inlining; remove dead code

This commit is contained in:
Simon Cruanes 2022-08-14 22:32:28 -04:00
parent 82691069f1
commit 23e70a192a
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
8 changed files with 12 additions and 21 deletions

View file

@ -180,14 +180,15 @@ let add_signature self (s : signature) (n : e_node) : unit =
on_backtrack self (fun () -> Sig_tbl.remove self.signatures_tbl s); on_backtrack self (fun () -> Sig_tbl.remove self.signatures_tbl s);
Sig_tbl.add self.signatures_tbl s n Sig_tbl.add self.signatures_tbl s n
let push_pending self t : unit = let[@inline] push_pending self t : unit =
Log.debugf 50 (fun k -> k "(@[<hv1>cc.push-pending@ %a@])" E_node.pp t); Log.debugf 50 (fun k -> k "(@[<hv1>cc.push-pending@ %a@])" E_node.pp t);
Vec.push self.pending t Vec.push self.pending t
let push_action self (a : Handler_action.t) : unit = let[@inline] push_action self (a : Handler_action.t) : unit =
Vec.push self.combine (CT_act a) Vec.push self.combine (CT_act a)
let push_action_l self (l : _ list) : unit = List.iter (push_action self) l let[@inline] push_action_l self (l : _ list) : unit =
List.iter (push_action self) l
let merge_classes self t u e : unit = let merge_classes self t u e : unit =
if t != u && not (same_class t u) then ( if t != u && not (same_class t u) then (
@ -544,7 +545,7 @@ and task_pending_ self (n : e_node) : unit =
) )
| Some s0 -> | Some s0 ->
(* update the signature by using [find] on each sub-e_node *) (* update the signature by using [find] on each sub-e_node *)
let s = update_sig s0 in let s = (update_sig [@inlined]) s0 in
(match find_signature self s with (match find_signature self s with
| None -> | None ->
(* add to the signature table [sig(n) --> n] *) (* add to the signature table [sig(n) --> n] *)

View file

@ -1,4 +1,5 @@
module View = View open Sidekick_core
module View = CC_view
module E_node = E_node module E_node = E_node
module Expl = Expl module Expl = Expl
module Signature = Signature module Signature = Signature

View file

@ -4,7 +4,7 @@ module type DYN_MONOID_PLUGIN = Sigs_plugin.DYN_MONOID_PLUGIN
module type MONOID_PLUGIN_ARG = Sigs_plugin.MONOID_PLUGIN_ARG module type MONOID_PLUGIN_ARG = Sigs_plugin.MONOID_PLUGIN_ARG
module type MONOID_PLUGIN_BUILDER = Sigs_plugin.MONOID_PLUGIN_BUILDER module type MONOID_PLUGIN_BUILDER = Sigs_plugin.MONOID_PLUGIN_BUILDER
module View = View module View = Sidekick_core.CC_view
module E_node = E_node module E_node = E_node
module Expl = Expl module Expl = Expl
module Signature = Signature module Signature = Signature

View file

@ -19,14 +19,7 @@ let equal (s1 : t) s2 : bool =
E_node.equal a1 a2 && E_node.equal b1 b2 && E_node.equal c1 c2 E_node.equal a1 a2 && E_node.equal b1 b2 && E_node.equal c1 c2
| Eq (a1, b1), Eq (a2, b2) -> E_node.equal a1 a2 && E_node.equal b1 b2 | Eq (a1, b1), Eq (a2, b2) -> E_node.equal a1 a2 && E_node.equal b1 b2
| Opaque u1, Opaque u2 -> E_node.equal u1 u2 | Opaque u1, Opaque u2 -> E_node.equal u1 u2
| Bool _, _ | (Bool _ | App_fun _ | App_ho _ | If _ | Eq _ | Opaque _ | Not _), _ -> false
| App_fun _, _
| App_ho _, _
| If _, _
| Eq _, _
| Opaque _, _
| Not _, _ ->
false
let hash (s : t) : int = let hash (s : t) : int =
let module H = CCHash in let module H = CCHash in
@ -40,7 +33,7 @@ let hash (s : t) : int =
H.combine4 60 (E_node.hash a) (E_node.hash b) (E_node.hash c) H.combine4 60 (E_node.hash a) (E_node.hash b) (E_node.hash c)
| Not u -> H.combine2 70 (E_node.hash u) | Not u -> H.combine2 70 (E_node.hash u)
let pp out = function let[@inline never] pp out = function
| Bool b -> Fmt.bool out b | Bool b -> Fmt.bool out b
| App_fun (f, []) -> Const.pp out f | App_fun (f, []) -> Const.pp out f
| App_fun (f, l) -> | App_fun (f, l) ->

View file

@ -1,4 +0,0 @@
(** Main types for congruence closure *)
open Sidekick_core
module View = View

View file

View file

View file

@ -8,7 +8,7 @@ type ('f, 't, 'ts) t =
| Opaque of 't | Opaque of 't
(* do not enter *) (* do not enter *)
let map_view ~f_f ~f_t ~f_ts (v : _ t) : _ t = let[@inline] map_view ~f_f ~f_t ~f_ts (v : _ t) : _ t =
match v with match v with
| Bool b -> Bool b | Bool b -> Bool b
| App_fun (f, args) -> App_fun (f_f f, f_ts args) | App_fun (f, args) -> App_fun (f_f f, f_ts args)
@ -18,7 +18,7 @@ let map_view ~f_f ~f_t ~f_ts (v : _ t) : _ t =
| Eq (a, b) -> Eq (f_t a, f_t b) | Eq (a, b) -> Eq (f_t a, f_t b)
| Opaque t -> Opaque (f_t t) | Opaque t -> Opaque (f_t t)
let iter_view ~f_f ~f_t ~f_ts (v : _ t) : unit = let[@inline] iter_view ~f_f ~f_t ~f_ts (v : _ t) : unit =
match v with match v with
| Bool _ -> () | Bool _ -> ()
| App_fun (f, args) -> | App_fun (f, args) ->