Switch Reaching analysis to use Finset for more efficiency
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -65,10 +65,10 @@ def lookupDef (prog : Program) (vs : VariableValues (DefSet prog) prog)
|
||||
(k : String) : DefSet prog :=
|
||||
if h : FiniteMap.MemKey k vs then (FiniteMap.locate h).1 else ⊥
|
||||
|
||||
/-- The AST node ids marked as definition sites in a `DefSet` (those mapped to
|
||||
`true`). With the AST-id-keyed lattice these are recovered directly. -/
|
||||
/-- The AST node ids marked as definition sites in a `DefSet`. With the
|
||||
`Finset`-of-AST-ids lattice these are just the elements of the set. -/
|
||||
def defSites (prog : Program) (d : DefSet prog) : List prog.NodeId :=
|
||||
(List.finRange prog.size).filter (fun i => d i)
|
||||
(List.finRange prog.size).filter (fun i => decide (i ∈ d))
|
||||
|
||||
/-- Is the candidate assignment loop-invariant: do all reaching definitions of
|
||||
its RHS variables lie outside the loop body? Reaching sets are now keyed by AST
|
||||
|
||||
Reference in New Issue
Block a user