From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.devel Subject: Re: Small LAP peephole optimization Date: Thu, 10 May 2007 18:21:07 +0400 Message-ID: <46432A53.5080906@yandex.ru> References: <4641A01D.5080206@yandex.ru> <8835CE25-48D2-4F9A-9DC3-81BC3CE49F4E@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1178806985 12994 80.91.229.12 (10 May 2007 14:23:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 May 2007 14:23:05 +0000 (UTC) Cc: emacs-devel@gnu.org To: Ken Raeburn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 10 16:23:03 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hm9Xq-0001A9-AC for ged-emacs-devel@m.gmane.org; Thu, 10 May 2007 16:23:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hm9f9-0004I7-I7 for ged-emacs-devel@m.gmane.org; Thu, 10 May 2007 10:30:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hm9f6-0004Fv-9k for emacs-devel@gnu.org; Thu, 10 May 2007 10:30:32 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hm9f4-0004E1-Vs for emacs-devel@gnu.org; Thu, 10 May 2007 10:30:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hm9f4-0004Du-QM for emacs-devel@gnu.org; Thu, 10 May 2007 10:30:30 -0400 Original-Received: from smtp2.yandex.ru ([213.180.200.18]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hm9Xe-0007D3-JT; Thu, 10 May 2007 10:22:50 -0400 Original-Received: from rtsoft2.corbina.net ([85.21.88.2]:54221 "EHLO [192.168.1.172]" smtp-auth: "dmantipov" TLS-CIPHER: TLS-PEER-CN1: ) by mail.yandex.ru with ESMTP id S4402107AbXEJOWk (ORCPT + 1 other); Thu, 10 May 2007 18:22:40 +0400 User-Agent: Thunderbird 1.5.0.7 (X11/20061008) In-Reply-To: <8835CE25-48D2-4F9A-9DC3-81BC3CE49F4E@gnu.org> X-detected-kernel: Linux 2.6 (newer, 1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:70764 Archived-At: 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 (byte-constant 0) (byte-plus . 0) -> 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