From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Newsgroups: gmane.lisp.guile.bugs Subject: bug#39573: [3.0.0] Compiler fails to optimize out side-effect-free expression Date: Thu, 13 Feb 2020 12:35:59 +0100 Message-ID: <87imka90tc.fsf@gnu.org> References: <87k14svxbf.fsf@gnu.org> <87lfp7am56.fsf@igalia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="11419"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: 39573-done@debbugs.gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Thu Feb 13 12:37:08 2020 Return-path: Envelope-to: guile-bugs@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 1j2Cns-0002ro-Hj for guile-bugs@m.gmane-mx.org; Thu, 13 Feb 2020 12:37:08 +0100 Original-Received: from localhost ([::1]:50892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Cnr-0006RD-KG for guile-bugs@m.gmane-mx.org; Thu, 13 Feb 2020 06:37:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33345) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Cnn-0006R2-7k for bug-guile@gnu.org; Thu, 13 Feb 2020 06:37:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2Cnm-0007GW-5g for bug-guile@gnu.org; Thu, 13 Feb 2020 06:37:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53407) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2Cnm-0007GN-2z for bug-guile@gnu.org; Thu, 13 Feb 2020 06:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j2Cnm-0000YO-08 for bug-guile@gnu.org; Thu, 13 Feb 2020 06:37:02 -0500 Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: bug-guile@gnu.org Resent-Date: Thu, 13 Feb 2020 11:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 39573 X-GNU-PR-Package: guile Mail-Followup-To: 39573@debbugs.gnu.org, ludo@gnu.org, ludo@gnu.org Original-Received: via spool by 39573-done@debbugs.gnu.org id=D39573.15815937702066 (code D ref 39573); Thu, 13 Feb 2020 11:37:01 +0000 Original-Received: (at 39573-done) by debbugs.gnu.org; 13 Feb 2020 11:36:10 +0000 Original-Received: from localhost ([127.0.0.1]:59379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2Cmw-0000XG-Cf for submit@debbugs.gnu.org; Thu, 13 Feb 2020 06:36:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46315) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2Cmu-0000X2-1v for 39573-done@debbugs.gnu.org; Thu, 13 Feb 2020 06:36:09 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j2Cmo-0005rG-GE; Thu, 13 Feb 2020 06:36:02 -0500 Original-Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=56034 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1j2Cmn-0007um-Pw; Thu, 13 Feb 2020 06:36:02 -0500 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 25 =?UTF-8?Q?Pluvi=C3=B4se?= an 228 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: <87lfp7am56.fsf@igalia.com> (Andy Wingo's message of "Wed, 12 Feb 2020 15:57:41 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9572 Archived-At: Hi Andy, Andy Wingo skribis: >> However, 3.0.0 keeps the computation of =E2=80=98i=E2=80=99: >> > [...] >> L3: >> 53 (instrument-loop 139)=20=20=20=20=20=20=20=20=20=20=20 >> 55 (handle-interrupts)=20=20=20=20=20=20=20=20=20=20=20=20=20 >> 56 (call-scm<-scm-uimm 5 5 1 3) at (unknow= n file):388:11 >> 58 (call-scm<-scm-uimm 3 3 1 34) at (unknow= n file):389:21 >> 60 (call-scm<-scm-scm 3 4 3 10) at (unknow= n file):389:11 >> 62 (=3D? 5 4) at (unkn= own file):385:11 >> 63 (jne -10) ;; -> L3 > > Hoo, we need to fix the disassembler to output something more sensible > than this :P IP 56 appears to be the 1-, 58 is the lsh/immediate, and > 60 is the logior. Oh, I hadn=E2=80=99t read that much into these lines. :-) >> I=E2=80=99m not sure where the optimization should be taking place. Per= haps >> it=E2=80=99s just a matter of amount-of-work threshold somewhere? > > It's not an amount-of-work, that's only in peval which does nothing to > either of these (though it certainly could). > > I took a look. I just pushed something to make (logior 0 INT) reduce to > INT, but it doesn't remove the loop variable. OK. > Then I thought it was surely dead code elimination that just wasn't > doing its thing. The value is unused, so it must be that it thought > that the `ash' was effectful. That `ash' gets compiled to > `lsh/immediate', which does indeed raise an exception if the operand > isn't an int; but here we prove that it is. The problem was a missing > "type checker" implementation for lsh/immediate, a problem introduced in > the refactored compilation of `ash'. So, fixed in git now: > > L3: > 45 (instrument-loop 135)=20=20=20=20=20=20=20=20=20=20=20 > 47 (handle-interrupts)=20=20=20=20=20=20=20=20=20=20=20=20=20 > 48 (call-scm<-scm-uimm 5 5 1 3) at (unknown= file):4:12 > 50 (=3D? 5 4) at (unkno= wn file):3:12 > 51 (jne -6) ;; -> L3 Yay! It=E2=80=99s nice to see how 7dc90a17e03045c7cd8894b14b027b845b68aa4f= is short and clear. Thanks, Ludo=E2=80=99.