This PR sorts the declarations fed into ElimDeadBranches in increasing
size. This can improve performance when we are dealing with a lot of
iterations.
The motivation for this change is as follows. Currently the algorithm
for doing one step of abstract interpretation is:
```
for decl in scc do
interpDecl
if summaryChanged decl then
return true
return false
```
whenever we return true we run another step. Now suppose we are in a
situation where we have an SCC with one big decl in the front and then
`n` small ones afterwards. For each time that the small ones change
their summary, we will re-run analysis of the big one in the front.
Currently the ordering is basically at "random" based on how other
compilers inject things into the SCC. This change ensures the behavior
is consistent and at least somewhat intelligent. By putting the small
declarations first, whenever we trigger a rerun of the loop we bias
analyzing the small declarations first, thus decreasing run time.
Note that this change does not have much effect on the current pipeline
because: We usually construct the SCCs in a way such that small ones
happen to be in front anyways. However, with upcomping changes on
specialization this is about to change.
38 lines
1.3 KiB
Text
38 lines
1.3 KiB
Text
[Compiler.IR] [reset_reuse]
|
|
def f (x_1 : obj) : obj :=
|
|
case x_1 : obj of
|
|
Prod.mk →
|
|
let x_2 : tobj := proj[0] x_1;
|
|
let x_3 : tobj := proj[1] x_1;
|
|
let x_5 : tobj := reset[2] x_1;
|
|
let x_4 : obj := reuse x_5 in ctor_0[Prod.mk] x_3 x_2;
|
|
ret x_4
|
|
[Compiler.IR] [reset_reuse]
|
|
def Sigma.toProd (x_1 : ◾) (x_2 : ◾) (x_3 : obj) : obj :=
|
|
let x_4 : obj := Sigma.toProd._redArg x_3;
|
|
ret x_4
|
|
def Sigma.toProd._redArg (x_1 : obj) : obj :=
|
|
case x_1 : obj of
|
|
Sigma.mk →
|
|
let x_2 : tobj := proj[0] x_1;
|
|
let x_3 : tobj := proj[1] x_1;
|
|
let x_5 : tobj := reset[2] x_1;
|
|
let x_4 : obj := reuse x_5 in ctor_0[Prod.mk] x_2 x_3;
|
|
ret x_4
|
|
[Compiler.IR] [reset_reuse]
|
|
def foo (x_1 : tobj) : tobj :=
|
|
case x_1 : tobj of
|
|
List.nil →
|
|
let x_2 : tagged := ctor_0[List.nil];
|
|
ret x_2
|
|
List.cons →
|
|
let x_3 : tobj := proj[0] x_1;
|
|
case x_3 : obj of
|
|
Prod.mk →
|
|
let x_4 : tobj := proj[1] x_1;
|
|
let x_10 : tobj := reset[2] x_1;
|
|
let x_5 : tobj := proj[0] x_3;
|
|
let x_6 : tobj := proj[1] x_3;
|
|
let x_7 : tobj := foo x_4;
|
|
let x_8 : obj := reuse x_10 in ctor_1[List.cons] x_5 x_7;
|
|
ret x_8
|