unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
To: guile-devel@gnu.org
Subject: Re: Adding Identities to Peval
Date: Thu, 16 Feb 2012 07:39:29 +0100	[thread overview]
Message-ID: <87pqdfb7tq.fsf@fencepost.gnu.org> (raw)
In-Reply-To: 87ty2rb9m5.fsf@fencepost.gnu.org

David Kastrup <dak@gnu.org> writes:

> Noah Lavine <noah.b.lavine@gmail.com> 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
>> don't know what they are. My working example has been this expression:
>>
>> (let* ((x (random))
>>        (y x))
>>   (eq? x y))
>>
>> The patch attached to this message lets peval optimize that to
>>
>> (begin (random) #t)
>
> I have a hard time imagining this optimization to be useful for any code
> occuring in practice.  Can you suggest an example that would make more
> sense than demonstrating that the optimization works?  Is this supposed
> to help with automatically generated code like macros?

Actually, I've been just racking my brain over how to write this better:

            {
	      // We end only one slur unless several ones have been
	      // caused by the same event, like with double slurs.
              if (!ended || scm_is_eq (starter,
				       slurs_[j]->get_property ("cause")))
		{
		  ended = true;
		  starter = slurs_[j]->get_property ("cause");
		  end_slurs_.push_back (slurs_[j]);
		  slurs_.erase (slurs_.begin () + j);
		}
            }

The problem is that if you enter the "if" through the second alternative
condition, you can just jump past the first two assignments (because
they assign values that are already known to be in the respective
variables).  I've not found a good way to handoptimize this short of
using goto or abusing do ... while;

-- 
David Kastrup




  reply	other threads:[~2012-02-16  6:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-16  1:29 Adding Identities to Peval Noah Lavine
2012-02-16  2:32 ` Mark H Weaver
2012-02-16  6:00 ` David Kastrup
2012-02-16  6:39   ` David Kastrup [this message]
2012-02-16  8:14     ` David Kastrup
2012-02-16  9:36 ` Andy Wingo
2012-02-16 13:18   ` Noah Lavine
2012-02-16 15:06     ` Andy Wingo
2012-02-16 17:33       ` Andy Wingo
2012-02-17  2:22       ` Noah Lavine
2012-02-17  8:13         ` Andy Wingo
2012-02-18 16:20           ` Noah Lavine
2012-02-19  9:53             ` Andy Wingo
2012-02-20 20:25               ` Noah Lavine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pqdfb7tq.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).