From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: Floating-point constant folding in Emacs byte compiler Date: Fri, 30 Mar 2018 16:26:52 +0000 Message-ID: References: <2ce39e5c-cd1b-65d6-b125-719caad67932@cs.ucla.edu> <83vadmgfbz.fsf@gnu.org> <87d0zr2n1u.fsf@gmail.com> <83h8p2g99p.fsf@gnu.org> <87370m3k4y.fsf@gmail.com> <838taeg6z5.fsf@gnu.org> <7a49cbdf-f2c3-0803-2ee8-3d9f55e405a5@cs.ucla.edu> <7a4f10ec-c1b9-953d-7a95-b2f1ff762735@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1522427204 784 195.159.176.226 (30 Mar 2018 16:26:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 30 Mar 2018 16:26:44 +0000 (UTC) Cc: Robert Pluim , emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 30 18:26:40 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f1wrP-00006A-P2 for ged-emacs-devel@m.gmane.org; Fri, 30 Mar 2018 18:26:39 +0200 Original-Received: from localhost ([::1]:50926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1wtT-0000eX-1S for ged-emacs-devel@m.gmane.org; Fri, 30 Mar 2018 12:28:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1wsJ-0000dL-9n for emacs-devel@gnu.org; Fri, 30 Mar 2018 12:27:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1wsI-0001Zw-BF for emacs-devel@gnu.org; Fri, 30 Mar 2018 12:27:35 -0400 Original-Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:51741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1wsI-0001XU-2g for emacs-devel@gnu.org; Fri, 30 Mar 2018 12:27:34 -0400 Original-Received: by mail-wm0-x236.google.com with SMTP id v21so16413116wmc.1 for ; Fri, 30 Mar 2018 09:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=R9YO/PNgsjcN0ROGaf4Bvwd/hX+VX6CPaSmOURItV2A=; b=bS24Gx0PcB7IIev6UkEfNgUtN5hUxn6rnmK9oZxzty4HX/t1qNNIAgBeLqqiXoyYfw +8R9VzM6Y5t3z2UXKFdEGevQsTB9lCnu2RujtlQAKYiazPa7FfW7bQXcC1lVEifjZFbE kQQv0CPDBHwZ2/O3dZYfqfSN5MWA9xqNdXvEf/5UEotcL0sB2zFQmdSpNqlZEC+8TPp0 t2EbF/XbZHIuIqyha2zJ3QAoMG25QnY+7BuYhep5EwbQaeQaPwxwgzcmVGEzkuakrBiT 1qYMCsG1HrNL8ZhdWMFaFYABeB3e4W057EcycESq61RX7MmBwPPxqn9afFBl23A+w6Iq u50A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=R9YO/PNgsjcN0ROGaf4Bvwd/hX+VX6CPaSmOURItV2A=; b=qBKrEIIdZPhfDe13/bg6Qlv0zrEDzzHChcrawMhFmwtG+jmwOA30z2vjuMY3ootVHl uMQo9sGEevjoCy0g7LyaVCy6KT/+j85sGTWtB+sBDPI9egnxWXy76Y7NvMwQwFZGuvr8 rpc9JlKEVertRvltTnzP7Hz3vgjIPKheihUYOP+OesNv3KGMwKHy8zWQdI5COb3eV1N8 S/F0TiJ/HvZ8flykV6xaHo+nE5LsMj5qh9OwOe1lds8aRi7+OzBfx7ymH7gpE2YSBTGL LnAqZQTC4iQ78Qaa1ZOcHHHsjKQFJ9PUEe/TeYF9mQodzsct1R2JJXDx2oFl39UOlqs/ bIpQ== X-Gm-Message-State: AElRT7EewY8XU1ZYx4TioshaH+1t/mzwzDTExPIqq8giArw0xO0v+6rN Xw9EEmsl36+ufsToYh4/sG6PoRuD76ZanSLDoSc= X-Google-Smtp-Source: AIpwx4+IeGZ+g0t6gcVoHN6w5GjKv5Q6VF4+yxdkzk3gHqBMELjis/DfFI5Ip2cwp+U+mfDjoxuxPRjcUooG+6+IEcE= X-Received: by 10.80.145.111 with SMTP id f44mr3475459eda.29.1522427252751; Fri, 30 Mar 2018 09:27:32 -0700 (PDT) Original-Received: by 10.80.129.230 with HTTP; Fri, 30 Mar 2018 09:26:52 -0700 (PDT) In-Reply-To: <7a4f10ec-c1b9-953d-7a95-b2f1ff762735@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:224182 Archived-At: Here's another interesting case of machine-dependent byte compliation: (defun f (x) (* (+ x 1024.0) (- x 1024.0))) (byte-compile 'f) The resulting constvec is [x 1024.0 1024.0] on this machine, but using NaN-boxed-doubles-as-Lisp-Objects, it's [x 1024.0]. It's easy enough to see why (identical float values aren't eq on standard Emacs), but it results in bytecode that's not only machine-dependent, but depends on details that aren't visible in the form's read syntax: (setq v 1024.0) (setq form1 '(lambda (x) (* (+ x 1024.0) (- x 1024.0)))) (setq form2 `(lambda (x) (* (+ x ,v) (- x ,v)))) (message "%S %S" form1 (byte-compile form1)) (message "%S %S" form2 (byte-compile form2)) produces: (lambda (x) (* (+ x 1024.0) (- x 1024.0))) #[(x) " \301\\ \302Z_\207" [x 1024.0 1024.0] 3] (lambda (x) (* (+ x 1024.0) (- x 1024.0))) #[(x) " \301\\ \301Z_\207" [x 1024.0] 3] It's easy to fix this by merging the constvec based on eql rather than eq, but that makes the byte compiler inconsistent: with optimization, (lambda () (eq 1024.0 1024.0)) will still be false, but without optimization, it will turn into bytecode that always returns true. This is biting me because I want bytecode to be exactly the same as on standard Emacs.