Closures passed to ilist.foreach/ilist.map often contain py.Constant statements that don't depend on the loop element. Unrolling/inlining these bodies re-materializes the constants per iteration, which blows up IR size and compile time.
Solution
A rewrite that lifts py.Constant (later, any loop-invariant pure statement) from a closure body into the enclosing region, iterating to fixpoint so constants escape nested foreach/map bodies.
Bodies that genuinely depend on the element are unaffected.
Closures passed to
ilist.foreach/ilist.mapoften contain py.Constant statements that don't depend on the loop element. Unrolling/inlining these bodies re-materializes the constants per iteration, which blows up IR size and compile time.Solution
A rewrite that lifts
py.Constant(later, any loop-invariant pure statement) from a closure body into the enclosing region, iterating to fixpoint so constants escape nested foreach/map bodies.Bodies that genuinely depend on the element are unaffected.