Open phischu opened 1 week ago
I think the key step for 2 is turning this:
def choice(n: Int){Fail} =
if (infixLt(n, 1)) {
val v_r: Nothing = Fail.fail();
v_r match {
}
} else {
choice(infixSub(n, 1), Fail)
}
into this:
def choice(n: Int){Fail} = {
def choice_helper(n: Int) = {
if (infixLt(n, 1)) {
val v_r: Nothing = Fail.fail();
v_r match {
}
} else {
choice_helper(infixSub(n, 1))
}
}
choice_helper(n)
}
That would allow choice
to be inlined, which then would make inlining Fail.fail()
possible.
I did this manually on countdown.effekt
and it helps a lot.
I have splitted the static argument transformation part into #690.
You are absolutely right about choice_helper
(usually called something with worker
).
@marvinborner wants to take on #690.
Consider the following program:
I contains a loop
choice
which can not and will not be inlined. After optimization we produce the following Core:The code for
new Fail { ... }
is duplicated, which also leads to duplicate allocations. We should not inline at all, only when there is an immediate redex. After this, the program should be:In some cases this could improve performance.