Variable splitting is a technique for eliminating unnecessary intermediate data structures in programs. It is also known as retyping [ref] and arity raising [ref], and it's related to unboxing[ref]. Eg
(define plus (lambda (p) (+ (car p) (cdr p)))) (define dumb (lambda (x) (plus (cons (sin x) x))))could be replaced with
(define plus1 (lambda (p1 p2) (+ p1 p2))) (define dumb (lambda (x) (plus1 (sin x) x)))
Though this is a general-purpose optimization, like inlining it is critically important to the quality of code produced by PE (see envs).
I plan to implement this in cogen
by making the following changes:
D
by generating cons instructions according to
the shape.
The root of this problem is in the binding time lattice. At cogen time the length of a list is not known; circular binding times forget exactly this. But once the static values have been received, this information can be recovered.
While the above plan looks rather ad hoc, I believe that it could
be much more simply implemented with a self-applicable specializer by
using a binding time lattice that captures as static information what
we put into the shape environment above. That is,
, etc.
D
D
= (cons D
D
)
[what is the state of the art in variable splitting for other systems?]