From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#42147: 28.0.50; pure vs side-effect-free, missing optimizations? Date: Thu, 2 Jul 2020 20:01:23 +0200 Message-ID: <28B19D86-343C-4126-B95F-1F38735F73F2@acm.org> References: <3A9CC2A3-8307-47B2-8D80-795C0AF020E1@acm.org> <0433A879-C98D-4B1A-B85C-A15DA9289099@acm.org> <1621669100.2102667.1593639091621@mail.yahoo.com> <775819003.2516724.1593687594435@mail.yahoo.com> <5F2B4684-34D1-4474-8909-9F435369FE54@acm.org> <705260433.2731607.1593698199171@mail.yahoo.com> <6CF8EE58-9A49-40E7-AA86-48AB39BF94BA@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_B6B517BA-361B-4B68-989C-2951E6CEB764" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10807"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Paul Eggert , Andrea Corallo , 42147@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 02 20:02:52 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jr3Xu-0002hQ-QY for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jul 2020 20:02:51 +0200 Original-Received: from localhost ([::1]:33350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr3Xt-0008PT-OU for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jul 2020 14:02:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr3X9-0007MF-5E for bug-gnu-emacs@gnu.org; Thu, 02 Jul 2020 14:02:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jr3X8-0004on-LE for bug-gnu-emacs@gnu.org; Thu, 02 Jul 2020 14:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jr3X8-0005d8-Id for bug-gnu-emacs@gnu.org; Thu, 02 Jul 2020 14:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Jul 2020 18:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42147 X-GNU-PR-Package: emacs Original-Received: via spool by 42147-submit@debbugs.gnu.org id=B42147.159371290521619 (code B ref 42147); Thu, 02 Jul 2020 18:02:02 +0000 Original-Received: (at 42147) by debbugs.gnu.org; 2 Jul 2020 18:01:45 +0000 Original-Received: from localhost ([127.0.0.1]:55602 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jr3Wr-0005cc-8s for submit@debbugs.gnu.org; Thu, 02 Jul 2020 14:01:45 -0400 Original-Received: from mail78c50.megamailservers.eu ([91.136.10.88]:54650 helo=mail70c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jr3Wn-0005cQ-Ru for 42147@debbugs.gnu.org; Thu, 02 Jul 2020 14:01:44 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1593712888; bh=yBtA0ffVrxKbf3Yz/c6JwQqy7d9/XJZ018ciqCnQ73Y=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=qfz5IHWfVhOnIXFS0YUVKckkiguSJAPX5e/cisP4OrAUGWHJcATivtsNo9Gbx/ue6 zT31L7GGioyqYxSHv1Zo7q8l5UFLAJdWej2Trl/wGg5fOzR8TAcLInxzONimMw4qlQ HI/MXaXDqFCUNzgqIRHvpsK/9bFMs0AZB+GTg7m0= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail70c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 062I1Od6022760; Thu, 2 Jul 2020 18:01:26 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F18.5EFE205C.0056, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=OKBZIhSB c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=iRZporoAAAAA:8 a=0cJY2SJWCGIAinVouL8A:9 a=QEXdDO2ut3YA:10 a=G1v6qB2zTqRmA-GjKukA:9 a=B2y7HmGcmWMA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182641 Archived-At: --Apple-Mail=_B6B517BA-361B-4B68-989C-2951E6CEB764 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 2 juli 2020 kl. 17.49 skrev Stefan Monnier : > Better yet, there's still hope that we change things such that `eq` > behaves like `eql` on bignums (and maybe also on floats). Speaking of which, Andrea may be in a good position to provide us with = performance data about such a change, since making 'eq' more expensive = is likely to be more visible in native code (assuming the operation is = open-coded) than in bytecode or interpreted lisp. On the other hand, = perhaps his compiler thingamajig is able to eliminate some checks = statically by type propagation? Anyway, since we now have bignums and have standardised on IEEE 754 = binary64 floats, is there a reason to keep byte-opt-portable-numberp? If we want to make allowance for capricious x87 rounding, what about = rewriting it to accept integral floats in the =C2=B12^53 range, as well = as any integer? This is what it might look like: --Apple-Mail=_B6B517BA-361B-4B68-989C-2951E6CEB764 Content-Disposition: attachment; filename=0001-Relax-portable-number-predicate-in-byte-compiler.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Relax-portable-number-predicate-in-byte-compiler.patch" Content-Transfer-Encoding: quoted-printable =46rom=20745752478c7ab895390a671ee4f7712eedf46bcc=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Thu,=202=20Jul=202020=2019:54:56=20+0200=0A= Subject:=20[PATCH]=20Relax=20portable=20number=20predicate=20in=20= byte-compiler=0A=0ASince=20Emacs=20has=20standardised=20on=20IEEE754=20= binary64,=20and=20the=20range=20of=0Aintegers=20is=20no=20longer=20= platform-dependent,=20all=20numbers=20are=20portable.=0ARetain=20a=20= restriction=20of=20floats=20to=20integers=20in=20[-2^53,2^53]=20to=20be=0A= safe=20against=20x87=20rounding=20errors=20(bug#42147).=0A=0A*=20= lisp/emacs-lisp/byte-opt.el=20(byte-opt--max-integral-float):=0A= (byte-opt--min-integral-float):=0A(byte-opt--portable-max):=0A= (byte-opt--portable-min):=0A(byte-opt--portable-numberp):=0A---=0A=20= lisp/emacs-lisp/byte-opt.el=20|=2027=20+++++++++++++--------------=0A=20= 1=20file=20changed,=2013=20insertions(+),=2014=20deletions(-)=0A=0Adiff=20= --git=20a/lisp/emacs-lisp/byte-opt.el=20b/lisp/emacs-lisp/byte-opt.el=0A= index=2072c68d64b2..2c7a23ebed=20100644=0A---=20= a/lisp/emacs-lisp/byte-opt.el=0A+++=20b/lisp/emacs-lisp/byte-opt.el=0A@@=20= -672,23=20+672,22=20@@=20byte-optimize-associative-math=0A=20=09=20=20=20= =20(apply=20(car=20form)=20constants))=0A=20=09form)))=0A=20=0A-;;=20= Portable=20Emacs=20integers=20fall=20in=20this=20range.=0A-(defconst=20= byte-opt--portable-max=20#x1fffffff)=0A-(defconst=20= byte-opt--portable-min=20(-=20-1=20byte-opt--portable-max))=0A+;;=20= Bounds=20of=20consecutive=20integers=20representable=20as=20floats.=0A= +;;=20These=20assume=20IEEE=20754=20binary64=20floats.=0A+(defconst=20= byte-opt--max-integral-float=20(float=20(ash=201=2053)))=0A+(defconst=20= byte-opt--min-integral-float=20(-=20byte-opt--max-integral-float))=0A=20=0A= =20;;=20True=20if=20N=20is=20a=20number=20that=20works=20the=20same=20on=20= all=20Emacs=20platforms.=0A-;;=20Portable=20Emacs=20fixnums=20are=20= exactly=20representable=20as=20floats=20on=20all=0A-;;=20Emacs=20= platforms,=20and=20(except=20for=20-0.0)=20any=20floating-point=20number=0A= -;;=20that=20equals=20one=20of=20these=20integers=20must=20be=20the=20= same=20on=20all=0A-;;=20platforms.=20=20Although=20other=20= floating-point=20numbers=20such=20as=200.5=20are=0A-;;=20also=20= portable,=20it=20can=20be=20tricky=20to=20characterize=20them=20portably=20= so=0A-;;=20they=20are=20not=20optimized.=0A+;;=20As=20long=20as=20we=20= need=20to=20support=2032-bit=20x86=20(using=20x87=20floats),=20we=20= cannot=0A+;;=20be=20certain=20that=20the=20result=20is=20portable=20to=20= the=20last=20bit=20for=20all=20values;=0A+;;=20therefore,=20we=20only=20= consider=20integral=20floats=20to=20be=20'portable'.=0A=20(defun=20= byte-opt--portable-numberp=20(n)=0A-=20=20(and=20(numberp=20n)=0A-=20=20=20= =20=20=20=20(<=3D=20byte-opt--portable-min=20n=20byte-opt--portable-max)=0A= -=20=20=20=20=20=20=20(=3D=20n=20(floor=20n))=0A-=20=20=20=20=20=20=20= (not=20(and=20(floatp=20n)=20(zerop=20n)=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(condition-case=20()=20(<=20(/=20n)=200)=20= (error))))))=0A+=20=20(or=20(integerp=20n)=0A+=20=20=20=20=20=20(and=20= (floatp=20n)=0A+=20=20=20=20=20=20=20=20=20=20=20(ignore-errors=20(=3D=20= n=20(floor=20n)))=0A+=20=20=20=20=20=20=20=20=20=20=20(<=3D=20= byte-opt--min-integral-float=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20n=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= byte-opt--max-integral-float))))=0A=20=0A=20;;=20Use=20OP=20to=20reduce=20= any=20leading=20prefix=20of=20portable=20numbers=20in=20the=20list=0A=20= ;;=20(cons=20ACCUM=20ARGS)=20down=20to=20a=20single=20portable=20number,=20= and=20return=20the=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_B6B517BA-361B-4B68-989C-2951E6CEB764--