Skip to content

Commit 1776758

Browse files
authored
perf: inline a few functions in the bv_decide circuit cache (#6889)
This PR inlines a few functions in the `bv_decide` circuit cache.
1 parent 5286b21 commit 1776758

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/Std/Sat/AIG/Basic.lean

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,18 @@ def Cache (α : Type) [DecidableEq α] [Hashable α] (decls : Array (Decl α)) :
7171
/--
7272
Create an empty `Cache`, valid with respect to any `Array Decl`.
7373
-/
74-
@[irreducible]
74+
@[irreducible, inline]
7575
def Cache.empty (decls : Array (Decl α)) : Cache α decls := ⟨{}, WF.empty⟩
7676

77-
@[inherit_doc Cache.WF.push_id, irreducible]
77+
@[inherit_doc Cache.WF.push_id, irreducible, inline]
7878
def Cache.noUpdate (cache : Cache α decls) : Cache α (decls.push decl) :=
7979
⟨cache.val, Cache.WF.push_id cache.property⟩
8080

8181
/-
8282
We require the `decls` as an explicit argument because we use `decls.size` so accidentally mutating
8383
`decls` before calling `Cache.insert` will destroy `decl` linearity.
8484
-/
85-
@[inherit_doc Cache.WF.push_cache, irreducible]
85+
@[inherit_doc Cache.WF.push_cache, irreducible, inline]
8686
def Cache.insert (decls : Array (Decl α)) (cache : Cache α decls) (decl : Decl α) :
8787
Cache α (decls.push decl) :=
8888
⟨cache.val.insert decl decls.size, Cache.WF.push_cache cache.property⟩
@@ -167,13 +167,8 @@ theorem Cache.get?_property {decls : Array (Decl α)} {idx : Nat} (c : Cache α
167167
/--
168168
Lookup a `Decl` in a `Cache`.
169169
-/
170-
opaque Cache.get? (cache : Cache α decls) (decl : Decl α) : Option (CacheHit decls decl) :=
171-
/-
172-
This function is marked as `opaque` to make sure it never, ever gets unfolded anywhere.
173-
Unfolding it will often cause `HashMap.find?` to be symbolically evaluated by reducing
174-
it either in `whnf` or in the kernel. This causes *huge* performance issues in practice.
175-
The function can still be fully verified as all the proofs we need are in `CacheHit`.
176-
-/
170+
@[irreducible, inline]
171+
def Cache.get? (cache : Cache α decls) (decl : Decl α) : Option (CacheHit decls decl) :=
177172
match hfound : cache.val[decl]? with
178173
| some hit =>
179174
some ⟨hit, Cache.get?_bounds _ _ hfound, Cache.get?_property _ _ hfound⟩

src/Std/Tactic/BVDecide/Bitblast/BVExpr/Basic.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ namespace Std.Tactic.BVDecide
2222
The variable definition used by the bitblaster.
2323
-/
2424
structure BVBit where
25-
/--
26-
The width of the BitVec variable.
27-
-/
28-
{w : Nat}
2925
/--
3026
A numeric identifier for the BitVec variable.
3127
-/
3228
var : Nat
3329
/--
30+
The width of the BitVec variable.
31+
-/
32+
{w : Nat}
33+
/--
3434
The bit that we take out of the BitVec variable by getLsb.
3535
-/
3636
idx : Fin w

0 commit comments

Comments
 (0)