unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: Ken Raeburn <raeburn@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Small LAP peephole optimization
Date: Thu, 10 May 2007 18:21:07 +0400	[thread overview]
Message-ID: <46432A53.5080906@yandex.ru> (raw)
In-Reply-To: <8835CE25-48D2-4F9A-9DC3-81BC3CE49F4E@gnu.org>

Ken Raeburn wrote:

> Now if the author of "foo" isn't sure that "quux" is going to return a 
> numeric value, removing the addition changes the semantics of "foo".

Yes. I understand this myself after a short meditation around the comment
above 'byte-compile-associative' :-).

> I would guess that in most of these cases it's a safe optimization, but 
> you should really check.

What do you think about such 'unsafe' optimizations in general ? As I know,
some CL systems (such as from Franz) allows byte compiler to be very aggressive
at the cost of safety.

> If the previous operation is guaranteed to leave a numeric value at the top
 > of the stack, as in your example, and no other code can branch to the +0 sequence,
 > then you can do the optimization; otherwise, you probably shouldn't.

As I understand, branching to +0 is impossible if there is no TAG between
previous byteop an (byte-constant 0), so we might safely optimize the
sequences like

<numeric-on-top-op> (byte-constant 0) (byte-plus . 0) -> <numeric-on-top-op>

Less obvious cases are also interesting, but I'm not sure that saving 2 ops
might push someone to implement substantially more complex logic.

Dmitry

  reply	other threads:[~2007-05-10 14:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-09 10:19 Small LAP peephole optimization Dmitry Antipov
2007-05-09 16:54 ` Ken Raeburn
2007-05-10 14:21   ` Dmitry Antipov [this message]
2007-05-10 20:10     ` Ken Raeburn
2007-05-09 21:34 ` Richard Stallman

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/emacs/

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

  git send-email \
    --in-reply-to=46432A53.5080906@yandex.ru \
    --to=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=raeburn@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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).