Re: Adding Identities to Peval

2012-02-20 Thread Noah Lavine
Done. I added two tests, for good measure :-). Noah On Sun, Feb 19, 2012 at 4:53 AM, Andy Wingo wrote: > On Sat 18 Feb 2012 17:20, Noah Lavine writes: > >> 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 >>

Re: Adding Identities to Peval

2012-02-19 Thread Andy Wingo
On Sat 18 Feb 2012 17:20, Noah Lavine writes: > 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? Looks good to me,

Re: Adding Identities to Peval

2012-02-18 Thread Noah Lavine
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

Re: Adding Identities to Peval

2012-02-17 Thread Andy Wingo
Hi Noah, On Fri 17 Feb 2012 03:22, Noah Lavine 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

Re: Adding Identities to Peval

2012-02-16 Thread Noah Lavine
Hello, On Thu, Feb 16, 2012 at 10:06 AM, Andy Wingo wrote: > On Thu 16 Feb 2012 14:18, Noah Lavine writes: > >>>  (let ((x (random))) >>>    (eq? x x)) >> >> (let* ((x (random)) >>        (y (list x)) >>        (z (car y)) >>   (eq? x z)) > > This one should reduce to the same thing, but current

Re: Adding Identities to Peval

2012-02-16 Thread Andy Wingo
On Thu 16 Feb 2012 16:06, Andy Wingo writes: > (list x) is not considered a "constant expression" because `let' is a > "constructor" I meant, `list' is a "constructor". A -- http://wingolog.org/

Re: Adding Identities to Peval

2012-02-16 Thread Andy Wingo
On Thu 16 Feb 2012 14:18, Noah Lavine writes: >>  (let ((x (random))) >>    (eq? x x)) > > (let* ((x (random)) >(y (list x)) >(z (car y)) > (eq? x z)) This one should reduce to the same thing, but currently doesn't because (list x) is not considered a "constant expression" beca

Re: Adding Identities to Peval

2012-02-16 Thread Noah Lavine
Hello, > Note, we don't need to add extra identities to operands: they already > have their gensyms.  So to get the effect of this patch, you could add a > clause to fold-constants: > >  ((primcall src 'eq? (lexical _ _ x) (lexical _ _ y)) >   (if (eq? x y) >       (make-const src #t) >       )) >

Re: Adding Identities to Peval

2012-02-16 Thread Andy Wingo
On Thu 16 Feb 2012 02:29, Noah Lavine writes: > (let* ((x (random)) >(y x)) > (eq? x y)) > > The patch attached to this message lets peval optimize that to > > (begin (random) #t) Neat :) Note, we don't need to add extra identities to operands: they already have their gensyms. So to

Re: Adding Identities to Peval

2012-02-16 Thread David Kastrup
David Kastrup writes: > David Kastrup writes: > >> Noah Lavine writes: >> >>> Hello, >>> >>> I've been working on a patch to add a new sort of optimization to >>> peval, and I think it's almost ready. It's based on some of the ideas >>> in "Environment Analysis of Higher-Order Languages". >>> >

Re: Adding Identities to Peval

2012-02-15 Thread David Kastrup
David Kastrup writes: > Noah Lavine writes: > >> Hello, >> >> I've been working on a patch to add a new sort of optimization to >> peval, and I think it's almost ready. It's based on some of the ideas >> in "Environment Analysis of Higher-Order Languages". >> >> The goal is to recognize when two

Re: Adding Identities to Peval

2012-02-15 Thread David Kastrup
Noah Lavine writes: > Hello, > > I've been working on a patch to add a new sort of optimization to > peval, and I think it's almost ready. It's based on some of the ideas > in "Environment Analysis of Higher-Order Languages". > > The goal is to recognize when two quantities are equal even when we

Re: Adding Identities to Peval

2012-02-15 Thread Mark H Weaver
Hi Noah, Noah Lavine writes: > I've been working on a patch to add a new sort of optimization to > peval, and I think it's almost ready. It's based on some of the ideas > in "Environment Analysis of Higher-Order Languages". Nice! :) > There's one glaring wart. The identity checking is activiate

Adding Identities to Peval

2012-02-15 Thread Noah Lavine
Hello, I've been working on a patch to add a new sort of optimization to peval, and I think it's almost ready. It's based on some of the ideas in "Environment Analysis of Higher-Order Languages". The goal is to recognize when two quantities are equal even when we don't know what they are. My work