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: Fri, 3 Jul 2020 20:43:57 +0200 Message-ID: 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> <28B19D86-343C-4126-B95F-1F38735F73F2@acm.org> <1288c6a5-545b-f68c-ff6b-7683db3e54c1@cs.ucla.edu> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_64FDEC5C-5CFF-4A2D-903C-FA5EBC80B4A0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9595"; 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 Fri Jul 03 20:45:15 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 1jrQgR-0002EN-1x for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Jul 2020 20:45:11 +0200 Original-Received: from localhost ([::1]:41334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrQgP-00016m-JB for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Jul 2020 14:45:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrQgI-00016d-RZ for bug-gnu-emacs@gnu.org; Fri, 03 Jul 2020 14:45:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jrQgI-0006Hn-HQ for bug-gnu-emacs@gnu.org; Fri, 03 Jul 2020 14:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jrQgI-0005CO-Ek for bug-gnu-emacs@gnu.org; Fri, 03 Jul 2020 14:45: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: Fri, 03 Jul 2020 18:45: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.159380185919921 (code B ref 42147); Fri, 03 Jul 2020 18:45:02 +0000 Original-Received: (at 42147) by debbugs.gnu.org; 3 Jul 2020 18:44:19 +0000 Original-Received: from localhost ([127.0.0.1]:57676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jrQfb-0005BD-2Z for submit@debbugs.gnu.org; Fri, 03 Jul 2020 14:44:19 -0400 Original-Received: from mail1446c50.megamailservers.eu ([91.136.14.46]:54572 helo=mail265c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jrQfY-0005B0-T0 for 42147@debbugs.gnu.org; Fri, 03 Jul 2020 14:44:18 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1593801841; bh=evUNqf3P8pNSTzSVBlRjW4SDdThjNUGAGBSkPZWYqbU=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=aAqLg/AVjnMXua0P6dwfxy9J/+JJCrlQf1bTRXFmIO46HRvv3XCMHv2xDv1oP/Q1B Sh1uqS2iQLC+jnQixia+1glFePqgRMoR+qM/6ogsdb2ugkcDhJIbNx0UxpH98h1vXd s2PwFzTcMD/h85vkMHJmi00iaWHnxSIXJuEEnTOw= 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 mail265c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 063Ihwca005275; Fri, 3 Jul 2020 18:44:00 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F22.5EFF7BC4.0070, 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=D5w51cZj c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=4K3v4Wtmzs6zsS628y4A:9 a=CjuIK1q_8ugA:10 a=AOTq0esIhStyUFMtzskA:9 a=B2y7HmGcmWMA:10 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:182670 Archived-At: --Apple-Mail=_64FDEC5C-5CFF-4A2D-903C-FA5EBC80B4A0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > patch attached Now. --Apple-Mail=_64FDEC5C-5CFF-4A2D-903C-FA5EBC80B4A0 Content-Disposition: attachment; filename=0001-Relax-portable-number-check-in-byte-compiler-bug-421.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Relax-portable-number-check-in-byte-compiler-bug-421.patch" Content-Transfer-Encoding: quoted-printable =46rom=207b0a5329706a6c73e49b5e3b464543f8ba94f21d=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Fri,=203=20Jul=202020=2020:13:50=20+0200=0A= Subject:=20[PATCH]=20Relax=20portable=20number=20check=20in=20byte=20= compiler=20(bug#42147)=0A=0AWith=20bignums,=20the=20set=20of=20= representable=20integers=20is=20no=20longer=0Aplatform-dependent,=20and=20= since=20we=20use=20nothing=20but=20IEEE754=2064-bit=0Afloats,=20all=20= numbers=20are=20now=20portable.=20=20Take=20advantage=20of=20this=20fact=0A= to=20simplify=20constant-folding=20in=20the=20byte=20compiler,=20= allowing=20it=20to=0Abe=20applied=20more=20widely.=0A=0A*=20= lisp/emacs-lisp/byte-opt.el=20(byte-opt--portable-max)=0A= (byte-opt--portable-min,=20byte-opt--portable-numberp):=20Remove.=0A= (byte-opt--arith-reduce,=20byte-optimize-minus,=20byte-optimize-1+)=0A= (byte-optimize-1-):=20Simplify:=20any=20number=20will=20do,=20and=20if=20= N=20is=20a=0Anumber,=20then=20so=20are=20-N,=20N+1=20and=20N-1.=0A---=0A=20= lisp/emacs-lisp/byte-opt.el=20|=2039=20= +++++++++----------------------------=0A=201=20file=20changed,=209=20= insertions(+),=2030=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/byte-opt.el=20b/lisp/emacs-lisp/byte-opt.el=0Aindex=20= 12bde8faf3..bf9e6a728a=20100644=0A---=20a/lisp/emacs-lisp/byte-opt.el=0A= +++=20b/lisp/emacs-lisp/byte-opt.el=0A@@=20-672,36=20+672,18=20@@=20= byte-optimize-associative-math=0A=20=09=20=20=20=20(apply=20(car=20form)=20= constants))=0A=20=09form)))=0A=20=0A-;;=20Portable=20Emacs=20integers=20= fall=20in=20this=20range.=0A-(defconst=20byte-opt--portable-max=20= #x1fffffff)=0A-(defconst=20byte-opt--portable-min=20(-=20-1=20= byte-opt--portable-max))=0A-=0A-;;=20True=20if=20N=20is=20a=20number=20= that=20works=20the=20same=20on=20all=20Emacs=20platforms.=0A-;;=20= Portable=20Emacs=20fixnums=20are=20exactly=20representable=20as=20floats=20= on=20all=0A-;;=20Emacs=20platforms,=20and=20(except=20for=20-0.0)=20any=20= floating-point=20number=0A-;;=20that=20equals=20one=20of=20these=20= integers=20must=20be=20the=20same=20on=20all=0A-;;=20platforms.=20=20= Although=20other=20floating-point=20numbers=20such=20as=200.5=20are=0A= -;;=20also=20portable,=20it=20can=20be=20tricky=20to=20characterize=20= them=20portably=20so=0A-;;=20they=20are=20not=20optimized.=0A-(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-=0A-;;=20Use=20OP=20to=20reduce=20any=20leading=20prefix=20= of=20portable=20numbers=20in=20the=20list=0A-;;=20(cons=20ACCUM=20ARGS)=20= down=20to=20a=20single=20portable=20number,=20and=20return=20the=0A+;;=20= Use=20OP=20to=20reduce=20any=20leading=20prefix=20of=20constant=20= numbers=20in=20the=20list=0A+;;=20(cons=20ACCUM=20ARGS)=20down=20to=20a=20= single=20number,=20and=20return=20the=0A=20;;=20resulting=20list=20A=20= of=20arguments.=20=20The=20idea=20is=20that=20applying=20OP=20to=20A=0A=20= ;;=20is=20equivalent=20to=20(but=20likely=20more=20efficient=20than)=20= applying=20OP=20to=0A=20;;=20(cons=20ACCUM=20ARGS),=20on=20any=20Emacs=20= platform.=20=20Do=20not=20make=20any=20special=0A=20;;=20provision=20for=20= (-=20X)=20or=20(/=20X);=20for=20example,=20it=20is=20the=20caller=E2=80=99= s=0A=20;;=20responsibility=20that=20(-=201=200)=20should=20not=20be=20= "optimized"=20to=20(-=201).=0A=20(defun=20byte-opt--arith-reduce=20(op=20= accum=20args)=0A-=20=20(when=20(byte-opt--portable-numberp=20accum)=0A+=20= =20(when=20(numberp=20accum)=0A=20=20=20=20=20(let=20(accum1)=0A-=20=20=20= =20=20=20(while=20(and=20(byte-opt--portable-numberp=20(car=20args))=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-opt--portable-numberp=0A+=20=20=20=20=20=20(while=20(and=20= (numberp=20(car=20args))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(numberp=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(setq=20accum1=20(condition-case=20()=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(funcall=20op=20accum=20(car=20args))=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(error))))=0A@@=20-746,12=20+728,11=20@@=20byte-optimize-minus=0A=20= =20=20=20=20=20=20=20;;=20(-=20x=20-1)=20-->=20(1+=20x)=0A=20=20=20=20=20= =20=20=20((equal=20(cdr=20args)=20'(-1))=0A=20=20=20=20=20=20=20=20=20= (list=20'1+=20(car=20args)))=0A-=20=20=20=20=20=20=20;;=20(-=20n)=20->=20= -n,=20where=20n=20and=20-n=20are=20portable=20numbers.=0A+=20=20=20=20=20= =20=20;;=20(-=20n)=20->=20-n,=20where=20n=20and=20-n=20are=20constant=20= numbers.=0A=20=20=20=20=20=20=20=20;;=20This=20must=20be=20done=20= separately=20since=20byte-opt--arith-reduce=0A=20=20=20=20=20=20=20=20;;=20= is=20not=20applied=20to=20(-=20n).=0A=20=20=20=20=20=20=20=20((and=20= (null=20(cdr=20args))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-opt--portable-numberp=20(car=20args))=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20(byte-opt--portable-numberp=20(-=20(car=20args))))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20(numberp=20(car=20args)))=0A=20=20=20=20=20= =20=20=20=20(-=20(car=20args)))=0A=20=20=20=20=20=20=20=20;;=20not=20= further=20optimized=0A=20=20=20=20=20=20=20=20((equal=20args=20(cdr=20= form))=20form)=0A@@=20-761,8=20+742,7=20@@=20byte-optimize-1+=0A=20=20=20= (let=20((args=20(cdr=20form)))=0A=20=20=20=20=20(when=20(null=20(cdr=20= args))=0A=20=20=20=20=20=20=20(let=20((n=20(car=20args)))=0A-=20=20=20=20= =20=20=20=20(when=20(and=20(byte-opt--portable-numberp=20n)=0A-=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(byte-opt--portable-numberp=20= (1+=20n)))=0A+=20=20=20=20=20=20=20=20(when=20(numberp=20n)=0A=20=20=20=20= =20=20=20=20=20=20=20(setq=20form=20(1+=20n))))))=0A=20=20=20form)=0A=20=0A= @@=20-770,8=20+750,7=20@@=20byte-optimize-1-=0A=20=20=20(let=20((args=20= (cdr=20form)))=0A=20=20=20=20=20(when=20(null=20(cdr=20args))=0A=20=20=20= =20=20=20=20(let=20((n=20(car=20args)))=0A-=20=20=20=20=20=20=20=20(when=20= (and=20(byte-opt--portable-numberp=20n)=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(byte-opt--portable-numberp=20(1-=20n)))=0A+=20= =20=20=20=20=20=20=20(when=20(numberp=20n)=0A=20=20=20=20=20=20=20=20=20=20= =20(setq=20form=20(1-=20n))))))=0A=20=20=20form)=0A=20=0A--=20=0A2.21.1=20= (Apple=20Git-122.3)=0A=0A= --Apple-Mail=_64FDEC5C-5CFF-4A2D-903C-FA5EBC80B4A0--