Received: (at 21883) by debbugs.gnu.org; 15 Oct 2018 07:09:01 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 15 03:09:01 2018 Received: from localhost ([127.0.0.1]:49734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1gBwzt-00030i-1P for submit <at> debbugs.gnu.org; Mon, 15 Oct 2018 03:09:01 -0400 Received: from mail-ua1-f41.google.com ([209.85.222.41]:43636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefan.itampe@HIDDEN>) id 1gBwzq-00030O-1T for 21883 <at> debbugs.gnu.org; Mon, 15 Oct 2018 03:08:59 -0400 Received: by mail-ua1-f41.google.com with SMTP id c89so1644526uac.10 for <21883 <at> debbugs.gnu.org>; Mon, 15 Oct 2018 00:08:58 -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=/qc5Ip8hNC/pcGnHbJP4W6ZUdi69jn1GEv96Av8wfxY=; b=ARxm1REjX0+RFLAmkeW+krcj1Pz6w1YeA4jUmb2YORQr1LLha3JyYoNgPebb00JRjT HyQUn/zxUsU0mJZVLLPIfpfaO80WrPPHYZMSU2A+vCnZ0kmGgg5pQdltTmrhekVUEufH tA0rrKj78zFWh0G3U+ypCp9/T8cP2FkNgbvlv243pI36ommcJA/oBVgwZnzLgX92ayiZ Vyxa3YQDjR1awgZ9ZFcciiuQc3vls31bFS6eM5hVxVPEU6j808qPVsXdAZji8wXD2dnh AzJEVg4FhXORw0HyAck/Gy+umtO6mx+qwHtSyoXwc0Mp4MDpDpP5i4XMWV41goMXMpiS R9yQ== 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=/qc5Ip8hNC/pcGnHbJP4W6ZUdi69jn1GEv96Av8wfxY=; b=lrr42hqmaiBpj3Q19Ehsz2kxcqAf45TirKBbhg/PZIQnjGo12NuuWa82kQnMhxiLha XP3uUOMx0+apAZI9/qLBb04+qMQ+ldamN/ZnMZOpvBTOTeWlqSscdJ+uM8XWIg0t7uRi 3JXNm16Uq44Rvzx9N1yBvBVZaiNj++u/o8bIeLUVSV4FfK1tcHQG+sSGhNjLkWNY7di0 tpmr0VjGqG7RH78T56sNJP5FGxAsZ3ZvqaGWpEtxgdYalAfW5vJidnN13ZJN3I2U6KuT f66HstGlg94m0/HZT9w7tbSVLaHVPIYKLtudtpqpMigP5RioulOTrXt8ti3KCslFdrWa +6Jw== X-Gm-Message-State: ABuFfogjvIFdC5K+Ty6V5juH7YH9UskCIwFeVcGOYIEFTcwcepW4EWhy VwGepMBhXh7ggOsn64pq7+kGUwgHs504kAVkjFE= X-Google-Smtp-Source: ACcGV60rFSp9CvZYLeQN6M94d4UCur+v6tRqLB0oIHmIUrbBj59KywlEeLPuP7+ttOQE4sdImaj3hq2LRHswHnvnEyU= X-Received: by 2002:ab0:24a:: with SMTP id 68-v6mr6861456uas.25.1539587332448; Mon, 15 Oct 2018 00:08:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1f:2801:0:0:0:0:0 with HTTP; Mon, 15 Oct 2018 00:08:51 -0700 (PDT) Received: by 2002:a1f:2801:0:0:0:0:0 with HTTP; Mon, 15 Oct 2018 00:08:51 -0700 (PDT) In-Reply-To: <87a7ngtblz.fsf@HIDDEN> References: <20151112070725.GA875@HIDDEN> <87tvlpszzu.fsf@HIDDEN> <CAGua6m1D3Ed-T3GJntfZr5QesTvR_Gf1-JbsiAetdoxBGkce_w@HIDDEN> <CAGua6m1CrfW2jEmQcDn_-1szGQbNcboBa45M6inEE5As6FToXw@HIDDEN> <CAGua6m1gnynxOxWsTEjf=EAMirWVp+bOP2aTsiLs=d1Z0UmdLw@HIDDEN> <87a7ngtblz.fsf@HIDDEN> From: Stefan Israelsson Tampe <stefan.itampe@HIDDEN> Date: Mon, 15 Oct 2018 09:08:51 +0200 Message-ID: <CAGua6m0iuBz3rSzYz_=NJD1a3KOEivdEQGF6VkYDq8GNaqCXKQ@HIDDEN> Subject: Re: bug#21883: unnecessary bit shifting range limits To: Mark H Weaver <mhw@HIDDEN> Content-Type: multipart/alternative; boundary="0000000000000d280605783f1ccc" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 21883 Cc: 21883 <at> debbugs.gnu.org, Zefram <zefram@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --0000000000000d280605783f1ccc Content-Type: text/plain; charset="UTF-8" i think you got it. sorry for the fuzz. Den 15 okt 2018 12:19 AM skrev "Mark H Weaver" <mhw@HIDDEN>: > Stefan Israelsson Tampe <stefan.itampe@HIDDEN> writes: > > how would this slow down the code. just add the correction where you > > throw the exception which should be in a branch outside the hot path. > > If you have a suggestion that's simpler than what I did in commits > 011aec7e, 9448a078, and 1990aa91, and just as fast in the common cases, > feel free to propose a patch. The words above are insufficient. > > Mark > --0000000000000d280605783f1ccc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">i think you got it. sorry for the fuzz.<div dir=3D"auto">= <br></div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">D= en 15 okt 2018 12:19 AM skrev "Mark H Weaver" <<a href=3D"mail= to:mhw@HIDDEN">mhw@HIDDEN</a>>:<br type=3D"attribution"><blockqu= ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s= olid;padding-left:1ex">Stefan Israelsson Tampe <<a href=3D"mailto:stefan= .itampe@HIDDEN">stefan.itampe@HIDDEN</a>> writes:<br> > how would this slow down the code. just add the correction where you<b= r> > throw the exception which should be in a branch outside the hot path.<= br> <br> If you have a suggestion that's simpler than what I did in commits<br> 011aec7e, 9448a078, and 1990aa91, and just as fast in the common cases,<br> feel free to propose a patch.=C2=A0 The words above are insufficient.<br> <br> =C2=A0 =C2=A0 =C2=A0 Mark<br> </blockquote></div></div> --0000000000000d280605783f1ccc--
bug-guile@HIDDEN
:bug#21883
; Package guile
.
Full text available.Received: (at 21883) by debbugs.gnu.org; 14 Oct 2018 22:19:58 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 14 18:19:58 2018 Received: from localhost ([127.0.0.1]:49655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1gBoju-0004Bp-7s for submit <at> debbugs.gnu.org; Sun, 14 Oct 2018 18:19:58 -0400 Received: from world.peace.net ([64.112.178.59]:47562) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mhw@HIDDEN>) id 1gBojs-0004BW-LY for 21883 <at> debbugs.gnu.org; Sun, 14 Oct 2018 18:19:56 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from <mhw@HIDDEN>) id 1gBojm-0006qq-TA; Sun, 14 Oct 2018 18:19:51 -0400 From: Mark H Weaver <mhw@HIDDEN> To: Stefan Israelsson Tampe <stefan.itampe@HIDDEN> Subject: Re: bug#21883: unnecessary bit shifting range limits References: <20151112070725.GA875@HIDDEN> <87tvlpszzu.fsf@HIDDEN> <CAGua6m1D3Ed-T3GJntfZr5QesTvR_Gf1-JbsiAetdoxBGkce_w@HIDDEN> <CAGua6m1CrfW2jEmQcDn_-1szGQbNcboBa45M6inEE5As6FToXw@HIDDEN> <CAGua6m1gnynxOxWsTEjf=EAMirWVp+bOP2aTsiLs=d1Z0UmdLw@HIDDEN> Date: Sun, 14 Oct 2018 18:19:36 -0400 In-Reply-To: <CAGua6m1gnynxOxWsTEjf=EAMirWVp+bOP2aTsiLs=d1Z0UmdLw@HIDDEN> (Stefan Israelsson Tampe's message of "Sun, 14 Oct 2018 11:46:12 +0200") Message-ID: <87a7ngtblz.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 21883 Cc: 21883 <at> debbugs.gnu.org, Zefram <zefram@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Stefan Israelsson Tampe <stefan.itampe@HIDDEN> writes: > how would this slow down the code. just add the correction where you > throw the exception which should be in a branch outside the hot path. If you have a suggestion that's simpler than what I did in commits 011aec7e, 9448a078, and 1990aa91, and just as fast in the common cases, feel free to propose a patch. The words above are insufficient. Mark
bug-guile@HIDDEN
:bug#21883
; Package guile
.
Full text available.Received: (at 21883) by debbugs.gnu.org; 14 Oct 2018 09:46:22 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 14 05:46:22 2018 Received: from localhost ([127.0.0.1]:48822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1gBcya-0007Na-88 for submit <at> debbugs.gnu.org; Sun, 14 Oct 2018 05:46:21 -0400 Received: from mail-vs1-f45.google.com ([209.85.217.45]:41125) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefan.itampe@HIDDEN>) id 1gBcyY-0007NN-El for 21883 <at> debbugs.gnu.org; Sun, 14 Oct 2018 05:46:18 -0400 Received: by mail-vs1-f45.google.com with SMTP id w1so14621935vsj.8 for <21883 <at> debbugs.gnu.org>; Sun, 14 Oct 2018 02:46:18 -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=mc/yHcYs1J7DueOSR5hws2qw/RAbYhrfI32wxdIvbtw=; b=veMc07NA1EeZvBxHZJK6GnWNrGbrbTXODbss+sHx1XIKOWFeLVdJb76bvKPUlrw32Q EUIw+v9iLV4H77x+VQwXrPaKTvLKk4Y5cWjN9sDG0b84tl28iwu9uICEyJEE4SUidd8N F8pZs/KIUHRE+bJ4hIyaouRkTjbujCNNiffO00mFUtSgVGRugbbRqj582NKlck6DSfvH QULR18K3/PzDH5z4o8GRhSKUGl12lZbcV76gQejBnRNegng++UOuJAmp1ngRSxhGap+c fHmG2jKvGwqjRW/9JuGn8sQ8MVlPpiD45vmWuBZaB24a7sMvuMMKtMc2NkYHA0NFv08R SvGQ== 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=mc/yHcYs1J7DueOSR5hws2qw/RAbYhrfI32wxdIvbtw=; b=tcqMmCehjJfT4cKZKYXM8q1DNBziZLbjjM6jPmMsLMS429s0TlIbL9XciwwzB+d3OG GFKwjz36iVomj1eoMaR4RTP0I2Spf8F77soaa6rvh1AUimL6dDIkY4rTTVygalTWLcCO /gZKJ5Ap1hsAC2ZFSObQjHYnq4Remuw6Vgs1q4/SgbGptCDBlpYJCh5S14oxK09riQ77 59yZayvAKz5gFTkaaEyYZHYexvMrUfikmvki0hAwcrS6FGuz1FgFPeXsQRZEewQFblnd Oi9VZ0Zr0LAcZ+O3C94UFrv4/lyz/LLuULc74lz0h7r2H0s3EAOHyzSTIRcPPh/+IxXc asVQ== X-Gm-Message-State: ABuFfoj8ZmTNxKVGxozFhbuzZO42WStG9d0jObFV17jXt+YK5BP0x7Bn oO2H7f80WdXNBoY6f/rNkFqsakhk9A/vtOnpDi9NFg== X-Google-Smtp-Source: ACcGV63QJK3bIexJFaVxEt2yXSeJMCYHDY/X6edaZvISQ6+DnkSBx+eb04M9fapuY+AGZqJsh3Ft3dahkV24TZrWhwY= X-Received: by 2002:a67:8801:: with SMTP id k1-v6mr153615vsd.103.1539510372636; Sun, 14 Oct 2018 02:46:12 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1f:2801:0:0:0:0:0 with HTTP; Sun, 14 Oct 2018 02:46:12 -0700 (PDT) Received: by 2002:a1f:2801:0:0:0:0:0 with HTTP; Sun, 14 Oct 2018 02:46:12 -0700 (PDT) In-Reply-To: <CAGua6m1CrfW2jEmQcDn_-1szGQbNcboBa45M6inEE5As6FToXw@HIDDEN> References: <20151112070725.GA875@HIDDEN> <87tvlpszzu.fsf@HIDDEN> <CAGua6m1D3Ed-T3GJntfZr5QesTvR_Gf1-JbsiAetdoxBGkce_w@HIDDEN> <CAGua6m1CrfW2jEmQcDn_-1szGQbNcboBa45M6inEE5As6FToXw@HIDDEN> From: Stefan Israelsson Tampe <stefan.itampe@HIDDEN> Date: Sun, 14 Oct 2018 11:46:12 +0200 Message-ID: <CAGua6m1gnynxOxWsTEjf=EAMirWVp+bOP2aTsiLs=d1Z0UmdLw@HIDDEN> Subject: Re: bug#21883: unnecessary bit shifting range limits To: Mark H Weaver <mhw@HIDDEN> Content-Type: multipart/alternative; boundary="000000000000e39c6605782d302f" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 21883 Cc: 21883 <at> debbugs.gnu.org, Zefram <zefram@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --000000000000e39c6605782d302f Content-Type: text/plain; charset="UTF-8" how would this slow down the code. just add the correction where you throw the exception which should be in a branch outside the hot path. Den 14 okt 2018 10:19 AM skrev "Mark H Weaver" <mhw@HIDDEN>: Zefram <zefram@HIDDEN> writes: > Not really outright bugs, but these responses are less than awesome: > > $ guile -c '(write (logbit? (ash 1 100) 123))' > ERROR: Value out of range 0 to 18446744073709551615: 1267650600228229401496703205376 > $ guile -c '(write (ash 0 (ash 1 100)))' > ERROR: Value out of range -9223372036854775808 to 9223372036854775807: 1267650600228229401496703205376 > $ guile -c '(write (ash 123 (ash -1 100)))' > ERROR: Value out of range -9223372036854775808 to 9223372036854775807: - 1267650600228229401496703205376 > > In all three cases, the theoretically-correct result of the expression > is not only representable but easily computed. Commit 011aec7e240ef987931548d90c53e6692c85d01c on the stable-2.2 branch extends 'ash' and 'round-ash' to handle the easily computed cases of huge shifts. > The functions could be improved to avoid failing in these cases, by > adding logic amounting to: > > (define (better-logbit? b v) > (if (>= b (integer-length v)) (< v 0) (logbit? b v))) > > (define (better-ash v s) > (cond > ((= v 0) 0) > ((<= s (- (integer-length v))) (if (< v 0) -1 0)) > (else (ash v s)))) Unfortunately, simple implementations like the ones above slow down the common case with expensive checks that are rarely needed. The aforementioned commit takes pains to avoid slowing down the common case, but at the cost of extra code complexity. In theory we could do something similar with many other procedures that implement operations on bits and bit fields, but I wonder if it's worth the extra complexity. Mark --000000000000e39c6605782d302f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">how would this slow down the code. just add the correctio= n where you throw the exception which should be in a branch outside the hot= path.</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">Den 1= 4 okt 2018 10:19 AM skrev "Mark H Weaver" <<a href=3D"mailto:m= hw@HIDDEN">mhw@HIDDEN</a>>:<br type=3D"attribution"><blockquote = class=3D"quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;paddi= ng-left:1ex">Zefram <<a href=3D"mailto:zefram@HIDDEN">zefram@HIDDEN<= /a>> writes:<br> <br> > Not really outright bugs, but these responses are less than awesome:<b= r> ><br> > $ guile -c '(write (logbit? (ash 1 100) 123))'<br> > ERROR: Value out of range 0 to 18446744073709551615: 12676506002282294= 0149670320537<wbr>6<br> > $ guile -c '(write (ash 0 (ash 1 100)))'<br> > ERROR: Value out of range -9223372036854775808 to 9223372036854775807:= 126765060022822940149670320537<wbr>6<br> > $ guile -c '(write (ash 123 (ash -1 100)))'<br> > ERROR: Value out of range -9223372036854775808 to 9223372036854775807:= -<wbr>126765060022822940149670320537<wbr>6<br> ><br> > In all three cases, the theoretically-correct result of the expression= <br> > is not only representable but easily computed.<br> <br> Commit 011aec7e240ef987931548d90c53e6<wbr>692c85d01c on the stable-2.2 bran= ch<br> extends 'ash' and 'round-ash' to handle the easily computed= cases of<br> huge shifts.<br> <br> > The functions could be improved to avoid failing in these cases, by<br= > > adding logic amounting to:<br> ><br> > (define (better-logbit? b v)<br> >=C2=A0 =C2=A0(if (>=3D b (integer-length v)) (< v 0) (logbit? b v= )))<br> ><br> > (define (better-ash v s)<br> >=C2=A0 =C2=A0(cond<br> >=C2=A0 =C2=A0 =C2=A0((=3D v 0) 0)<br> >=C2=A0 =C2=A0 =C2=A0((<=3D s (- (integer-length v))) (if (< v 0) = -1 0))<br> >=C2=A0 =C2=A0 =C2=A0(else (ash v s))))<br> <br> Unfortunately, simple implementations like the ones above slow down the<br> common case with expensive checks that are rarely needed.=C2=A0 The<br> aforementioned commit takes pains to avoid slowing down the common case,<br= > but at the cost of extra code complexity.<br> <br> In theory we could do something similar with many other procedures that<br> implement operations on bits and bit fields, but I wonder if it's worth= <br> the extra complexity.<br> <font color=3D"#888888"><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Mark<br> <br> <br> <br> </font></blockquote></div><br></div> --000000000000e39c6605782d302f--
bug-guile@HIDDEN
:bug#21883
; Package guile
.
Full text available.Received: (at 21883) by debbugs.gnu.org; 14 Oct 2018 08:18:40 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 14 04:18:40 2018 Received: from localhost ([127.0.0.1]:48758 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1gBbbk-0005Jm-7H for submit <at> debbugs.gnu.org; Sun, 14 Oct 2018 04:18:40 -0400 Received: from world.peace.net ([64.112.178.59]:39288) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mhw@HIDDEN>) id 1gBbbi-0005JV-9f for 21883 <at> debbugs.gnu.org; Sun, 14 Oct 2018 04:18:38 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from <mhw@HIDDEN>) id 1gBbbb-0001vj-Jl; Sun, 14 Oct 2018 04:18:31 -0400 From: Mark H Weaver <mhw@HIDDEN> To: Zefram <zefram@HIDDEN> Subject: Re: bug#21883: unnecessary bit shifting range limits References: <20151112070725.GA875@HIDDEN> Date: Sun, 14 Oct 2018 04:18:13 -0400 In-Reply-To: <20151112070725.GA875@HIDDEN> (Zefram's message of "Thu, 12 Nov 2015 07:07:25 +0000") Message-ID: <87tvlpszzu.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 21883 Cc: 21883 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Zefram <zefram@HIDDEN> writes: > Not really outright bugs, but these responses are less than awesome: > > $ guile -c '(write (logbit? (ash 1 100) 123))' > ERROR: Value out of range 0 to 18446744073709551615: 1267650600228229401496703205376 > $ guile -c '(write (ash 0 (ash 1 100)))' > ERROR: Value out of range -9223372036854775808 to 9223372036854775807: 1267650600228229401496703205376 > $ guile -c '(write (ash 123 (ash -1 100)))' > ERROR: Value out of range -9223372036854775808 to 9223372036854775807: -1267650600228229401496703205376 > > In all three cases, the theoretically-correct result of the expression > is not only representable but easily computed. Commit 011aec7e240ef987931548d90c53e6692c85d01c on the stable-2.2 branch extends 'ash' and 'round-ash' to handle the easily computed cases of huge shifts. > The functions could be improved to avoid failing in these cases, by > adding logic amounting to: > > (define (better-logbit? b v) > (if (>= b (integer-length v)) (< v 0) (logbit? b v))) > > (define (better-ash v s) > (cond > ((= v 0) 0) > ((<= s (- (integer-length v))) (if (< v 0) -1 0)) > (else (ash v s)))) Unfortunately, simple implementations like the ones above slow down the common case with expensive checks that are rarely needed. The aforementioned commit takes pains to avoid slowing down the common case, but at the cost of extra code complexity. In theory we could do something similar with many other procedures that implement operations on bits and bit fields, but I wonder if it's worth the extra complexity. Mark
bug-guile@HIDDEN
:bug#21883
; Package guile
.
Full text available.Received: (at submit) by debbugs.gnu.org; 12 Nov 2015 07:08:01 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 12 02:08:01 2015 Received: from localhost ([127.0.0.1]:33937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ZwlzF-0006BK-3E for submit <at> debbugs.gnu.org; Thu, 12 Nov 2015 02:08:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52311) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from <zefram@HIDDEN>) id 1Zwlyu-0006At-Mu for submit <at> debbugs.gnu.org; Thu, 12 Nov 2015 02:07:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1Zwlyt-00021h-OW for submit <at> debbugs.gnu.org; Thu, 12 Nov 2015 02:07:40 -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.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33891) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1Zwlyt-00021Y-Ly for submit <at> debbugs.gnu.org; Thu, 12 Nov 2015 02:07:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1Zwlys-0005G1-VJ for bug-guile@HIDDEN; Thu, 12 Nov 2015 02:07:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1Zwlyo-00020W-NF for bug-guile@HIDDEN; Thu, 12 Nov 2015 02:07:38 -0500 Received: from river.fysh.org ([87.98.248.19]:42505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1Zwlyo-000201-G6 for bug-guile@HIDDEN; Thu, 12 Nov 2015 02:07:34 -0500 Received: from zefram by river.fysh.org with local (Exim 4.80 #2 (Debian)) id 1Zwlyf-0001Bq-Oo; Thu, 12 Nov 2015 07:07:25 +0000 Date: Thu, 12 Nov 2015 07:07:25 +0000 From: Zefram <zefram@HIDDEN> To: bug-guile@HIDDEN Subject: unnecessary bit shifting range limits Message-ID: <20151112070725.GA875@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.0 (----) Not really outright bugs, but these responses are less than awesome: $ guile -c '(write (logbit? (ash 1 100) 123))' ERROR: Value out of range 0 to 18446744073709551615: 1267650600228229401496703205376 $ guile -c '(write (ash 0 (ash 1 100)))' ERROR: Value out of range -9223372036854775808 to 9223372036854775807: 1267650600228229401496703205376 $ guile -c '(write (ash 123 (ash -1 100)))' ERROR: Value out of range -9223372036854775808 to 9223372036854775807: -1267650600228229401496703205376 In all three cases, the theoretically-correct result of the expression is not only representable but easily computed. The functions could be improved to avoid failing in these cases, by adding logic amounting to: (define (better-logbit? b v) (if (>= b (integer-length v)) (< v 0) (logbit? b v))) (define (better-ash v s) (cond ((= v 0) 0) ((<= s (- (integer-length v))) (if (< v 0) -1 0)) (else (ash v s)))) -zefram
Zefram <zefram@HIDDEN>
:bug-guile@HIDDEN
.
Full text available.bug-guile@HIDDEN
:bug#21883
; Package guile
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.