[Larceny-users] Commutativity

William D Clinger will at ccs.neu.edu
Mon Feb 12 11:58:48 EST 2007


Jed Davis wrote:
> Well, this is... interesting.  There are two casualties of the MacScheme
> accumulator here, exemplified by:

Exactly right.  I think the order-of-evaluation
is being chosen without regard to whether the
expressions are operands to a primitive.  When
they are, the first operand should be evaluated
last unless there is some good reason not to.

The best solution would be to rewrite the code
generator yet again, but a good interim solution
would be to improve the choice of order of
evaluation, assuming the R6RS lets us do that.

> 1. The op2imm seems to come from cg-integrable-call2 in pass4p2, which
>    could also check on the constancy and immediate-worthiness of the
>    first argument.
> 
> 2. The reuse of RESULT I eventually traced to cg-let1-result and
>    cg-let-used-once in pass4let, which have enough information to flip
>    primitives that would benefit from it (and so avoid the allocation
>    and use of a temporary).

Generally speaking, I think it's best to handle
this sort of thing through a source transformation
as early as possible, e.g. pass 2 or 3.  As of now
I don't think commutativity is used to enable
op2imm, and is not recorded declaratively.  It
should be.  This should wait until after conversion
to R6RS, however, because the relevant compiler
tables will have to change to accomodate the R6RS
library feature.

Will



More information about the Larceny-users mailing list