[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding Identities to Peval

From: Noah Lavine
Subject: Re: Adding Identities to Peval
Date: Sat, 18 Feb 2012 11:20:01 -0500

Here is another patch that fixes the first of my examples. (let* ((x
(random)) (y x)) (eq? x y)) now folds to (begin (random) #t). It
turned out to be much smaller than the previous approach. Is it all
right if I push this?

I'm not sure how to make the other one work yet, but I will think about it.

I will send a separate email about the CPS stuff.


On Fri, Feb 17, 2012 at 3:13 AM, Andy Wingo <address@hidden> wrote:
> Hi Noah,
> On Fri 17 Feb 2012 03:22, Noah Lavine <address@hidden> writes:
>>>> (let* ((x (random))
>>>>        (y (list x))
>>>>        (z (car y))
>>>>   (eq? x z))
>> To make sure I understand, in the x-y-z example, psyntax would produce
>> different gensyms for x and z, but peval could merge them later on,
>> right?
> When processing `z' for value, it should reduce to `x'.  The strategy is
> to do computation at compile time -- if at compile time, `z' can reduce
> to `x', peval will do it.  But there is no global "give me all the
> things that are equal to x" procedure.
>> In that case, peval would maintain the invariant "if two values must
>> always be the same, they have the same gensym". Correct?
> More like the other way around!  If one identifier partially evaluates
> to another, then they will have the same gensym, and therefore are the
> same identifier.
>>> This is related to range analysis.  But, it's also something that's
>>> easier to do with an explicit notion of control flow (i.e. a CPS IR).
>> Yes, I think you're right. I would be very interested in working on a
>> CPS IR, but I remember you had a blog post a couple months ago where
>> you said you weren't sure if CPS or ANF was better for Guile. What do
>> you think about intermediate representations now?
> I have no idea :-) I am a little hesitant to move to either one right
> now, because our stack machine penalizes named temporaries, and with CPS
> (or ANF -- which is closer to what we have, but without the advantage of
> treating control flow on a first-class level) you would get a lot more
> named temporaries.  But my uncertainty is also because I don't know what
> it would make the compiler look like.  Would it simplify things or would
> it add complication?  I don't know.
> But, writing a pass to turn tree-il into some CPS language would be a
> really interesting step in any case.  If you wanted to work on that, I'm
> sure it would be instructive to us all.
> My humble thoughts :)
> Cheers,
> Andy
> --

Attachment: 0001-Optimize-Equality-Primitives.patch
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]