From unknown Sun Jun 15 08:35:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#39573: [3.0.0] Compiler fails to optimize out side-effect-free expression Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: wingo@igalia.com, bug-guile@gnu.org Resent-Date: Wed, 12 Feb 2020 11:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39573 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: bug-Guile@gnu.org Cc: wingo@igalia.com X-Debbugs-Original-Xcc: wingo@igalia.com Received: via spool by submit@debbugs.gnu.org id=B.158150825116332 (code B ref -1); Wed, 12 Feb 2020 11:51:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Feb 2020 11:50:51 +0000 Received: from localhost ([127.0.0.1]:57909 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1qXb-0004FL-6M for submit@debbugs.gnu.org; Wed, 12 Feb 2020 06:50:51 -0500 Received: from lists.gnu.org ([209.51.188.17]:48977) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1qXY-0004FD-Rz for submit@debbugs.gnu.org; Wed, 12 Feb 2020 06:50:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49659) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1qXX-0001p8-GC for bug-Guile@gnu.org; Wed, 12 Feb 2020 06:50:48 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_20 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j1qXX-0002Dd-Ca for bug-Guile@gnu.org; Wed, 12 Feb 2020 06:50:47 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=35376 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1j1qXX-0001PI-07 for bug-Guile@gnu.org; Wed, 12 Feb 2020 06:50:47 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 24 =?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 Date: Wed, 12 Feb 2020 12:50:44 +0100 Message-ID: <87k14svxbf.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello! Consider this loop: (let loop ((n (expt 2 18)) (i 1)) (unless (zero? n) (loop (- n 1) (logior 0 (ash i 1))))) Guile 2.2 strips away the computation of =E2=80=98i=E2=80=99 (it cannot thr= ow, has no side effects, and the result is unused): --8<---------------cut here---------------start------------->8--- 0 (assert-nargs-ee/locals 1 4) ;; 5 slots (0 args) at (unknown f= ile):16:10 1 (current-module 4)=20=20=20=20=20=20=20=20=20=20=20=20=20=20 2 (static-set! 4 74) ;; #f 4 (toplevel-box 4 84 72 82 #t) ;; `expt' 9 (box-ref 2 4)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 10 (make-short-immediate 1 10) ;; 2 11 (make-short-immediate 0 74) ;; 18 12 (handle-interrupts) at (unknown f= ile):16:24 13 (call 2 3)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 15 (receive 0 2 5)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 17 (load-u64 3 0 0) at (unknown f= ile):18:11 20 (br-if-u64-=3D-scm 3 4 #f 12) ;; -> L2 23 (sub/immediate 4 4 1) at (unknown f= ile):21:11 24 (br-if-u64-=3D-scm 3 4 #f 8) ;; -> L2 at (unknown= file):18:11 L1: 27 (handle-interrupts) at (unknown f= ile):21:11 28 (sub/immediate 4 4 1)=20=20=20=20=20=20=20=20=20=20=20 29 (br-if-u64-=3D-scm 3 4 #t -2) ;; -> L1 at (unknown= file):18:11 L2: 32 (make-short-immediate 3 2052) ;; # at (unknown f= ile):21:11 33 (handle-interrupts)=20=20=20=20=20=20=20=20=20=20=20=20=20 34 (return-values 2) ;; 1 value --8<---------------cut here---------------end--------------->8--- However, 3.0.0 keeps the computation of =E2=80=98i=E2=80=99: --8<---------------cut here---------------start------------->8--- 0 (instrument-entry 192) at (unknown f= ile):383:9 2 (assert-nargs-ee/locals 1 5) ;; 6 slots (0 args) 3 (call-scm<-thread 5 62)=20=20=20=20=20=20=20=20=20 5 (static-set! 5 147) ;; #f 7 (static-ref 5 147) ;; #f 9 (immediate-tag=3D? 5 7 0) ;; heap-object? 11 (je 19) ;; -> L2 12 (static-ref 5 140) ;; #f 14 (static-ref 4 150) ;; expt 16 (call-scm<-scm-scm 5 5 4 40)=20=20=20=20 18 (immediate-tag=3D? 5 7 0) ;; heap-object? 20 (jne 8) ;; -> L1 21 (scm-ref/immediate 3 5 1)=20=20=20=20=20=20=20 22 (immediate-tag=3D? 3 4095 2308) ;; undefined? 24 (je 4) ;; -> L1 25 (static-set! 5 129) ;; #f 27 (j 3) ;; -> L2 L1: 28 (throw/value 4 156) ;; #(unbound-variable #f "Unbound v= ariable: ~S") L2: 30 (scm-ref/immediate 2 5 1)=20=20=20=20=20=20=20 31 (make-short-immediate 1 10) ;; 2 32 (make-short-immediate 0 74) ;; 18 33 (handle-interrupts) at (unknown f= ile):383:23 34 (call 3 3)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 36 (receive 0 3 6)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 38 (make-short-immediate 4 2) ;; 0 at (unknown f= ile):385:11 39 (=3D? 5 4)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 40 (je 24) ;; -> L4 41 (call-scm<-scm-uimm 5 5 1 3) at (unknown f= ile):388:11 43 (load-s64 3 0 0) at (unknown f= ile):389:11 46 (load-s64 2 0 2)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 49 (ulogior 3 3 2)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 50 (tag-fixnum 3 3)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 51 (=3D? 5 4) at (unknown= file):385:11 52 (je 12) ;; -> L4 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 (unknown f= ile):388:11 58 (call-scm<-scm-uimm 3 3 1 34) at (unknown f= ile):389:21 60 (call-scm<-scm-scm 3 4 3 10) at (unknown f= ile):389:11 62 (=3D? 5 4) at (unknown= file):385:11 63 (jne -10) ;; -> L3 L4: 64 (make-short-immediate 5 2052) ;; # at (unknown f= ile):388:5 65 (reset-frame 1) ;; 1 slot 66 (handle-interrupts)=20=20=20=20=20=20=20=20=20=20=20=20=20 67 (return-values)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 --8<---------------cut here---------------end--------------->8--- I=E2=80=99m not sure where the optimization should be taking place. Perhaps it=E2=80=99s just a matter of amount-of-work threshold somewhere? Thanks, Ludo=E2=80=99. From unknown Sun Jun 15 08:35:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#39573: [3.0.0] Compiler fails to optimize out side-effect-free expression Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 12 Feb 2020 14:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39573 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: bug-Guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15815194969364 (code B ref -1); Wed, 12 Feb 2020 14:59:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 Feb 2020 14:58:16 +0000 Received: from localhost ([127.0.0.1]:58924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1tSy-0002Qw-AN for submit@debbugs.gnu.org; Wed, 12 Feb 2020 09:58:16 -0500 Received: from lists.gnu.org ([209.51.188.17]:52461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1tSw-0002Qo-OB for submit@debbugs.gnu.org; Wed, 12 Feb 2020 09:58:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50651) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1tSv-0007FA-0O for bug-Guile@gnu.org; Wed, 12 Feb 2020 09:58:14 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1tSs-00084y-Qv for bug-Guile@gnu.org; Wed, 12 Feb 2020 09:58:11 -0500 Received: from fanzine.igalia.com ([178.60.130.6]:34053) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j1tSs-0007qG-8G; Wed, 12 Feb 2020 09:58:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From; bh=VCDAsNfZ5rY7jg4dIErl1pQfPDpyoVlBTRBXeSW6NTI=; b=g6SmVYbh4cpZXQSxboLd4lCbzBm0wkHclYgQUULSo8RUisRKDKkTDEX79BxcT33x6QHaFzBQrSwsaAWLpUJdlFcliKN2UdBh8bAK4DIl6qrr28S9fqRznzd73LhRaF+s9AuPwyNlFWiDwv34Hl3NX0TJDP5m7YKjIRFQofKoIbkOWFuuBpbYjGzB5BB0oJZHxKD4Yxr0s3JMzib1lzDzRVRC7JgN+4fcFBvIkQ/u3d3kjqRRpApHQ5kqF1z44nt77m6yV+AlPVzFjUemEpRAkvnFlNyhGzsjWLMvi/SL5e4fvte5fhv08aePXZtU3zrCzpJT6HY3RmpAwgOkXc2eNw==; Received: from lfbn-ann-1-376-195.w86-200.abo.wanadoo.fr ([86.200.91.195] helo=milano) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1j1tSZ-0002RO-FL; Wed, 12 Feb 2020 15:57:51 +0100 From: Andy Wingo References: <87k14svxbf.fsf@gnu.org> Date: Wed, 12 Feb 2020 15:57:41 +0100 In-Reply-To: <87k14svxbf.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Wed, 12 Feb 2020 12:50:44 +0100") Message-ID: <87lfp7am56.fsf@igalia.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Wed 12 Feb 2020 12:50, Ludovic Court=C3=A8s writes: > Hello! > > Consider this loop: > > (let loop ((n (expt 2 18)) > (i 1)) > (unless (zero? n) > (loop (- n 1) > (logior 0 (ash i 1))))) > > Guile 2.2 strips away the computation of =E2=80=98i=E2=80=99 (it cannot t= hrow, has no > side effects, and the result is unused): > [...] > L1: > 27 (handle-interrupts) at (unknown= file):21:11 > 28 (sub/immediate 4 4 1)=20=20=20=20=20=20=20=20=20=20=20 > 29 (br-if-u64-=3D-scm 3 4 #t -2) ;; -> L1 at (unkno= wn file):18:11 Like specifically, it removes the logior call. > 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 (unknown= file):388:11 > 58 (call-scm<-scm-uimm 3 3 1 34) at (unknown= file):389:21 > 60 (call-scm<-scm-scm 3 4 3 10) at (unknown= file):389:11 > 62 (=3D? 5 4) at (unkno= wn 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. > I=E2=80=99m not sure where the optimization should be taking place. Perh= aps > 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. 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 f= ile):4:12 50 (=3D? 5 4) at (unknown= file):3:12 51 (jne -6) ;; -> L3 Cheers, Andy From unknown Sun Jun 15 08:35:41 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#39573: closed (Re: bug#39573: [3.0.0] Compiler fails to optimize out side-effect-free expression) Message-ID: References: <87imka90tc.fsf@gnu.org> <87k14svxbf.fsf@gnu.org> X-Gnu-PR-Message: they-closed 39573 X-Gnu-PR-Package: guile Reply-To: 39573@debbugs.gnu.org Date: Thu, 13 Feb 2020 11:37:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1581593822-2125-1" This is a multi-part message in MIME format... ------------=_1581593822-2125-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #39573: [3.0.0] Compiler fails to optimize out side-effect-free expression which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 39573@debbugs.gnu.org. --=20 39573: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D39573 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1581593822-2125-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 39573-done) by debbugs.gnu.org; 13 Feb 2020 11:36:10 +0000 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 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 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 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 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Andy Wingo Subject: Re: bug#39573: [3.0.0] Compiler fails to optimize out side-effect-free expression References: <87k14svxbf.fsf@gnu.org> <87lfp7am56.fsf@igalia.com> 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 Date: Thu, 13 Feb 2020 12:35:59 +0100 In-Reply-To: <87lfp7am56.fsf@igalia.com> (Andy Wingo's message of "Wed, 12 Feb 2020 15:57:41 +0100") Message-ID: <87imka90tc.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 39573-done Cc: 39573-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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. ------------=_1581593822-2125-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 Feb 2020 11:50:51 +0000 Received: from localhost ([127.0.0.1]:57909 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1qXb-0004FL-6M for submit@debbugs.gnu.org; Wed, 12 Feb 2020 06:50:51 -0500 Received: from lists.gnu.org ([209.51.188.17]:48977) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j1qXY-0004FD-Rz for submit@debbugs.gnu.org; Wed, 12 Feb 2020 06:50:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49659) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1qXX-0001p8-GC for bug-Guile@gnu.org; Wed, 12 Feb 2020 06:50:48 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_20 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j1qXX-0002Dd-Ca for bug-Guile@gnu.org; Wed, 12 Feb 2020 06:50:47 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=35376 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1j1qXX-0001PI-07 for bug-Guile@gnu.org; Wed, 12 Feb 2020 06:50:47 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: bug-Guile@gnu.org Subject: [3.0.0] Compiler fails to optimize out side-effect-free expression X-Debbugs-Cc: wingo@igalia.com X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 24 =?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 Date: Wed, 12 Feb 2020 12:50:44 +0100 Message-ID: <87k14svxbf.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello! Consider this loop: (let loop ((n (expt 2 18)) (i 1)) (unless (zero? n) (loop (- n 1) (logior 0 (ash i 1))))) Guile 2.2 strips away the computation of =E2=80=98i=E2=80=99 (it cannot thr= ow, has no side effects, and the result is unused): --8<---------------cut here---------------start------------->8--- 0 (assert-nargs-ee/locals 1 4) ;; 5 slots (0 args) at (unknown f= ile):16:10 1 (current-module 4)=20=20=20=20=20=20=20=20=20=20=20=20=20=20 2 (static-set! 4 74) ;; #f 4 (toplevel-box 4 84 72 82 #t) ;; `expt' 9 (box-ref 2 4)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 10 (make-short-immediate 1 10) ;; 2 11 (make-short-immediate 0 74) ;; 18 12 (handle-interrupts) at (unknown f= ile):16:24 13 (call 2 3)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 15 (receive 0 2 5)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 17 (load-u64 3 0 0) at (unknown f= ile):18:11 20 (br-if-u64-=3D-scm 3 4 #f 12) ;; -> L2 23 (sub/immediate 4 4 1) at (unknown f= ile):21:11 24 (br-if-u64-=3D-scm 3 4 #f 8) ;; -> L2 at (unknown= file):18:11 L1: 27 (handle-interrupts) at (unknown f= ile):21:11 28 (sub/immediate 4 4 1)=20=20=20=20=20=20=20=20=20=20=20 29 (br-if-u64-=3D-scm 3 4 #t -2) ;; -> L1 at (unknown= file):18:11 L2: 32 (make-short-immediate 3 2052) ;; # at (unknown f= ile):21:11 33 (handle-interrupts)=20=20=20=20=20=20=20=20=20=20=20=20=20 34 (return-values 2) ;; 1 value --8<---------------cut here---------------end--------------->8--- However, 3.0.0 keeps the computation of =E2=80=98i=E2=80=99: --8<---------------cut here---------------start------------->8--- 0 (instrument-entry 192) at (unknown f= ile):383:9 2 (assert-nargs-ee/locals 1 5) ;; 6 slots (0 args) 3 (call-scm<-thread 5 62)=20=20=20=20=20=20=20=20=20 5 (static-set! 5 147) ;; #f 7 (static-ref 5 147) ;; #f 9 (immediate-tag=3D? 5 7 0) ;; heap-object? 11 (je 19) ;; -> L2 12 (static-ref 5 140) ;; #f 14 (static-ref 4 150) ;; expt 16 (call-scm<-scm-scm 5 5 4 40)=20=20=20=20 18 (immediate-tag=3D? 5 7 0) ;; heap-object? 20 (jne 8) ;; -> L1 21 (scm-ref/immediate 3 5 1)=20=20=20=20=20=20=20 22 (immediate-tag=3D? 3 4095 2308) ;; undefined? 24 (je 4) ;; -> L1 25 (static-set! 5 129) ;; #f 27 (j 3) ;; -> L2 L1: 28 (throw/value 4 156) ;; #(unbound-variable #f "Unbound v= ariable: ~S") L2: 30 (scm-ref/immediate 2 5 1)=20=20=20=20=20=20=20 31 (make-short-immediate 1 10) ;; 2 32 (make-short-immediate 0 74) ;; 18 33 (handle-interrupts) at (unknown f= ile):383:23 34 (call 3 3)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 36 (receive 0 3 6)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 38 (make-short-immediate 4 2) ;; 0 at (unknown f= ile):385:11 39 (=3D? 5 4)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 40 (je 24) ;; -> L4 41 (call-scm<-scm-uimm 5 5 1 3) at (unknown f= ile):388:11 43 (load-s64 3 0 0) at (unknown f= ile):389:11 46 (load-s64 2 0 2)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 49 (ulogior 3 3 2)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 50 (tag-fixnum 3 3)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 51 (=3D? 5 4) at (unknown= file):385:11 52 (je 12) ;; -> L4 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 (unknown f= ile):388:11 58 (call-scm<-scm-uimm 3 3 1 34) at (unknown f= ile):389:21 60 (call-scm<-scm-scm 3 4 3 10) at (unknown f= ile):389:11 62 (=3D? 5 4) at (unknown= file):385:11 63 (jne -10) ;; -> L3 L4: 64 (make-short-immediate 5 2052) ;; # at (unknown f= ile):388:5 65 (reset-frame 1) ;; 1 slot 66 (handle-interrupts)=20=20=20=20=20=20=20=20=20=20=20=20=20 67 (return-values)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 --8<---------------cut here---------------end--------------->8--- I=E2=80=99m not sure where the optimization should be taking place. Perhaps it=E2=80=99s just a matter of amount-of-work threshold somewhere? Thanks, Ludo=E2=80=99. ------------=_1581593822-2125-1-- From unknown Sun Jun 15 08:35:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#39573: [3.0.0] Compiler fails to optimize out side-effect-free expression Resent-From: Mikael Djurfeldt Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 13 Feb 2020 15:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39573 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 39573@debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Andy Wingo , 39573-done@debbugs.gnu.org Reply-To: mikael@djurfeldt.com Received: via spool by 39573-submit@debbugs.gnu.org id=B39573.158160669129742 (code B ref 39573); Thu, 13 Feb 2020 15:12:02 +0000 Received: (at 39573) by debbugs.gnu.org; 13 Feb 2020 15:11:31 +0000 Received: from localhost ([127.0.0.1]:60341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2G9L-0007jd-Hp for submit@debbugs.gnu.org; Thu, 13 Feb 2020 10:11:31 -0500 Received: from mail-vs1-f48.google.com ([209.85.217.48]:36468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2G9J-0007jK-J3; Thu, 13 Feb 2020 10:11:29 -0500 Received: by mail-vs1-f48.google.com with SMTP id a2so4131818vso.3; Thu, 13 Feb 2020 07:11:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=/k8WVTTRF8R/tes5fsPHInD4QhFpOaOdwEuiGEfiymk=; b=tK8QA2Ze1up8+2gWOVDZzo/G5KDkmHH/KRNO9P8uD4nGjAo3SUYDdkSAMBRS2yjocF kXTW9U4jITUrHJQhMzsqSJSQR8IDM/nNwXirBm0swv7PLbhNvCyrvIsZCuhBfbEy7TXl FPEnW5S1E2zHp8N3sx0i20XDjKn98aVo337eqw3nLy1DANqRSwvYne6+R39r6qsrWkMX 3NYDFfdHuIRDbcJnDK5XLkuxn/pUazhJShhal2m6pjtyUw5bJiNUcfCStxfMOcd1XPp6 mQy/Si+1q3zsrbh8H9dkCm36JfnRj0eKsTvqBSac02pKa+M6PQEdTxJNhX6UMs4djjhz wBUA== X-Gm-Message-State: APjAAAWZB0tFPEezuWcvNPILCc3+1dIwvannVZnFQZeUiVxwVljLlgSi rPwgqCgkn8Exgrj/EhuKy502+fXpNMt4NmLTc/PFJzXC X-Google-Smtp-Source: APXvYqzAK0/lrXj+LGwbsp7dwywmm8HrppEiwN+hAzRYYiLour8KIJgwAHNVhGkko5NoMAZOYhPkISHHv2jtugeUzac= X-Received: by 2002:a05:6102:126c:: with SMTP id q12mr2243922vsg.212.1581606683798; Thu, 13 Feb 2020 07:11:23 -0800 (PST) MIME-Version: 1.0 References: <87k14svxbf.fsf@gnu.org> <87lfp7am56.fsf@igalia.com> <87imka90tc.fsf@gnu.org> In-Reply-To: <87imka90tc.fsf@gnu.org> From: Mikael Djurfeldt Date: Thu, 13 Feb 2020 16:11:11 +0100 Message-ID: Content-Type: multipart/alternative; boundary="0000000000008ff1b9059e7680a0" X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) --0000000000008ff1b9059e7680a0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Den tors 13 feb. 2020 12:37Ludovic Court=C3=A8s skrev: > Yay! It=E2=80=99s nice to see how 7dc90a17e03045c7cd8894b14b027b845b68aa= 4f is > short and clear. > > Thanks, > Ludo=E2=80=99. > (You're lucky, Ludo', that we don't take that statement literally. :-)) Thanks! > --0000000000008ff1b9059e7680a0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Den tors 13 feb. 2020 12:37Ludovic Court=C3=A8s <ludo@gnu.org> skrev:
Yay!=C2=A0 It=E2=80=99s nice to see how 7dc90a17e03045c7cd8894b14b027b845b6= 8aa4f is
short and clear.

Thanks,
Ludo=E2=80=99.

(You're lucky, Ludo', that we don't take that sta= tement literally. :-))

T= hanks!
--0000000000008ff1b9059e7680a0-- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 08 10:56:16 2020 Received: (at control) by debbugs.gnu.org; 8 Mar 2020 14:56:16 +0000 Received: from localhost ([127.0.0.1]:49164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAxLk-00035U-JI for submit@debbugs.gnu.org; Sun, 08 Mar 2020 10:56:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47423) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAxLj-00035H-HS for control@debbugs.gnu.org; Sun, 08 Mar 2020 10:56:15 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54454) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jAxLe-0006FD-Af for control@debbugs.gnu.org; Sun, 08 Mar 2020 10:56:10 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=35500 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jAxLd-0002mL-Hp for control@debbugs.gnu.org; Sun, 08 Mar 2020 10:56:10 -0400 Date: Sun, 08 Mar 2020 15:56:08 +0100 Message-Id: <87a74qc2uv.fsf@gnu.org> To: control@debbugs.gnu.org From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: control message for bug #39573 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) retitle 39573 [3.0.0] Compiler fails to optimize (logior 0 INT) quit