Inefficient lowering in static-inliner
pass
#1447
Labels
Calyx 2.0
Things that move us towards Calyx 2.0
Milestone
static-inliner
pass
#1447
The current
static-inliner
pass works in a "bottom up" manner.The
inline_static_control()
function is the key inlining function here.To understand how it works, consider an example:
static seq {stmt1; stmt2; stmt3;}
. It will first compilestmt1
,stmt2
, andstmt3
into static groups by recursively callinginline_static_control()
on eachstmt
. Then it will rewrite the assignments in each of the groups corresponding tostmt1
,stmt2
, andstmt3
, before finally placing all of those assignments into a single static group (that represents the entirestatic seq
) and returning that single static group.An inefficiency comes in from the fact that if a static group is nested within$n$ levels of control, then its assignments will get rewritten $n$ times. (This is also why this pass generates redundant guards, and is the motivation behind the
simplify-static-guards
pass)Ideally, we only would need to rewrite these assignments once (when turning the "static island" into a static group). This would require a "top down" approach. We should have some sort of data structure that maps groups to their appropriate "offset" (which is updated throughout the recursive calls to
inline_static_control
), and then, at the end when we're compiling the static island into a single static group, we should "realize" the offsets just once by rewriting the assignments.One thing to note is that (after running
simplify-static-guards
) this shouldn't affect the performance of the compiled code; it's just inefficient for the compiler to keep on unnecessarily rewriting these assignments.The text was updated successfully, but these errors were encountered: