Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"All these black people are screwing up my democracy." - Ian Smith


devel / comp.lang.forth / Re: Optimizing #

SubjectAuthor
* Optimizing #Anton Ertl
+- Re: Optimizing #Ron AARON
+* Re: Optimizing #Krishna Myneni
|+* Re: Optimizing #minf...@arcor.de
||+- Re: Optimizing #Krishna Myneni
||+* Re: Optimizing #Anton Ertl
|||+* Re: Optimizing #Marcel Hendrix
||||`- Re: Optimizing #Marcel Hendrix
|||`- Re: Optimizing #Hans Bezemer
||+- Re: Optimizing #Rick C
||`* Re: Optimizing #dxforth
|| `- Re: Optimizing #Rick C
|`* Re: Optimizing #Krishna Myneni
| +- Re: Optimizing #Krishna Myneni
| `* Re: Optimizing #dxforth
|  +* Re: Optimizing #Krishna Myneni
|  |`* Re: Optimizing #dxforth
|  | `* Re: Optimizing #Heinrich Hohl
|  |  +* Re: Optimizing #Heinrich Hohl
|  |  |`- Re: Optimizing #dxforth
|  |  +- Re: Optimizing #Hans Bezemer
|  |  +- Re: Optimizing #Hans Bezemer
|  |  `- Re: Optimizing #dxforth
|  `- Re: Optimizing #Hans Bezemer
+* Re: Optimizing #Brian Fox
|+* Re: Optimizing #Anton Ertl
||`* Re: Optimizing #Paul Rubin
|| +* Re: Optimizing #dxforth
|| |`- Re: Optimizing #Paul Rubin
|| `* Re: Optimizing #Anton Ertl
||  `* Re: Optimizing #Paul Rubin
||   +- Re: Optimizing #dxforth
||   `* Re: Optimizing #minf...@arcor.de
||    `* Re: Optimizing #Paul Rubin
||     `* Re: Optimizing #minf...@arcor.de
||      +* Re: Optimizing #Marcel Hendrix
||      |+* Re: Optimizing #Marcel Hendrix
||      ||`- Re: Optimizing #Marcel Hendrix
||      |`* Re: Optimizing #minf...@arcor.de
||      | +- Re: Optimizing #Paul Rubin
||      | +- Re: Optimizing #minf...@arcor.de
||      | `* Re: Optimizing #Paul Rubin
||      |  `* Re: Optimizing #minf...@arcor.de
||      |   `- Re: Optimizing #Anton Ertl
||      +* Re: Optimizing #dxforth
||      |`* Re: Optimizing #Paul Rubin
||      | `* Re: Optimizing #dxforth
||      |  +* Re: Optimizing #minf...@arcor.de
||      |  |`- Re: Optimizing #dxforth
||      |  `* Re: Optimizing #Anton Ertl
||      |   `- Re: Optimizing #dxforth
||      `- Re: Optimizing # , float conv & BigNums,Jan Coombs
|+- Re: Optimizing #Rick C
|`- Re: Optimizing #dxforth
+- Re: Optimizing #Anton Ertl
`* Re: Optimizing #dxforth
 `* Re: Optimizing #Anton Ertl
  +- Re: Optimizing #Anton Ertl
  `* Re: Optimizing #dxforth
   `* Re: Optimizing #Anton Ertl
    `* Re: Optimizing #dxforth
     `* Re: Optimizing #Brian Fox
      `* Re: Optimizing #dxforth
       `* Re: Optimizing #Brian Fox
        `* Re: Optimizing #Anton Ertl
         `* Re: Optimizing #Anton Ertl
          `* Re: Optimizing #minf...@arcor.de
           `* Re: Optimizing #Hans Bezemer
            +* Re: Optimizing #Anton Ertl
            |`* Re: Optimizing #Hans Bezemer
            | `* Re: Optimizing #Paul Rubin
            |  `* Re: Optimizing #Marcel Hendrix
            |   `* Re: Optimizing #dxforth
            |    `* Re: Optimizing #Anton Ertl
            |     `- Re: Optimizing #dxforth
            `* Re: Optimizing #dxforth
             `* Re: Optimizing #Hans Bezemer
              `* Re: Optimizing #minf...@arcor.de
               `* Re: Optimizing #Hans Bezemer
                `* Re: Optimizing #minf...@arcor.de
                 `* Re: Optimizing #Hans Bezemer
                  `* Re: Optimizing #dxforth
                   `- Re: Optimizing #Hans Bezemer

Pages:1234
Re: Optimizing #

<78151848-9ba8-4883-abe7-99ba7942e00en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17355&group=comp.lang.forth#17355

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:23c8:b0:432:e69f:5d77 with SMTP id hr8-20020a05621423c800b00432e69f5d77mr10006133qvb.7.1647698432420;
Sat, 19 Mar 2022 07:00:32 -0700 (PDT)
X-Received: by 2002:a05:622a:388:b0:2e1:f007:ae9f with SMTP id
j8-20020a05622a038800b002e1f007ae9fmr9328220qtx.534.1647698432263; Sat, 19
Mar 2022 07:00:32 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 19 Mar 2022 07:00:31 -0700 (PDT)
In-Reply-To: <t11c5o$bim$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
<t10smb$15d$1@dont-email.me> <t11c5o$bim$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <78151848-9ba8-4883-abe7-99ba7942e00en@googlegroups.com>
Subject: Re: Optimizing #
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Sat, 19 Mar 2022 14:00:32 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: Hans Bezemer - Sat, 19 Mar 2022 14:00 UTC

On Friday, March 18, 2022 at 8:25:47 AM UTC+1, dxforth wrote:
> M/MOD ud1 u2 --- u3 ud4
> An unsigned mixed magnitude math operation which leaves a
> double quotient ud4 and remainder u3, from a double
> dividend ud1 and single divisor u2.
>
> Other names for it include MU/MOD (F83, F-PC). In all cases it was used
> to implement (not surprisingly) # .

I know it by the name of MU/MOD too - and in 4tH it is used to define
the double word version of # (like ESP32-Forth, 4tH's # is single word).

4tH's (library) version of UD/MOD is much more elaborate and has this
stack diagram: ( ud1 ud2 -- ud3 ud4)

It is also used in D/MOD ( d1 d2 -- d3 d4).

Hans Bezemer

Re: Optimizing #

<fffd71b1-40b1-484c-ae7b-34e2dee8af71n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17356&group=comp.lang.forth#17356

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:444a:b0:67d:2087:c1cd with SMTP id w10-20020a05620a444a00b0067d2087c1cdmr8610854qkp.90.1647699308076;
Sat, 19 Mar 2022 07:15:08 -0700 (PDT)
X-Received: by 2002:ac8:5a88:0:b0:2e1:bbda:3b21 with SMTP id
c8-20020ac85a88000000b002e1bbda3b21mr10779180qtc.307.1647699307946; Sat, 19
Mar 2022 07:15:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 19 Mar 2022 07:15:07 -0700 (PDT)
In-Reply-To: <c7413ef6-ae02-4abc-878d-43b5ec6e8366n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
<t10smb$15d$1@dont-email.me> <t11c5o$bim$1@gioia.aioe.org>
<t123f0$pd5$1@dont-email.me> <t139kr$13tb$1@gioia.aioe.org> <c7413ef6-ae02-4abc-878d-43b5ec6e8366n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fffd71b1-40b1-484c-ae7b-34e2dee8af71n@googlegroups.com>
Subject: Re: Optimizing #
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Sat, 19 Mar 2022 14:15:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 9
 by: Hans Bezemer - Sat, 19 Mar 2022 14:15 UTC

On Saturday, March 19, 2022 at 2:07:31 PM UTC+1, Heinrich Hohl wrote:
> : D* ( d1 n+ -- d2) DUP ROT * ROT ROT UM* ROT + ;

I know that thingy as:

: mu* swap over * >r um* r> + ;

Which is just about the same thing ;-)

Hans Bezemer

Re: Optimizing #

<7ca331e8-1dee-4f6f-99a7-2b4a05589b20n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17357&group=comp.lang.forth#17357

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:3184:b0:67d:cce9:bab4 with SMTP id bi4-20020a05620a318400b0067dcce9bab4mr8401095qkb.685.1647699478122;
Sat, 19 Mar 2022 07:17:58 -0700 (PDT)
X-Received: by 2002:a37:b707:0:b0:662:ef77:a69e with SMTP id
h7-20020a37b707000000b00662ef77a69emr8410501qkf.419.1647699477974; Sat, 19
Mar 2022 07:17:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 19 Mar 2022 07:17:57 -0700 (PDT)
In-Reply-To: <c7413ef6-ae02-4abc-878d-43b5ec6e8366n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t0fjr2$6h3$1@dont-email.me>
<t10smb$15d$1@dont-email.me> <t11c5o$bim$1@gioia.aioe.org>
<t123f0$pd5$1@dont-email.me> <t139kr$13tb$1@gioia.aioe.org> <c7413ef6-ae02-4abc-878d-43b5ec6e8366n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7ca331e8-1dee-4f6f-99a7-2b4a05589b20n@googlegroups.com>
Subject: Re: Optimizing #
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Sat, 19 Mar 2022 14:17:58 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: Hans Bezemer - Sat, 19 Mar 2022 14:17 UTC

On Saturday, March 19, 2022 at 2:07:31 PM UTC+1, Heinrich Hohl wrote:
> : D* ( d1 n+ -- d2) DUP ROT * ROT ROT UM* ROT + ;
BTW, I know this one as:

( d1 d2 -- d3)
: d* >r swap >r over over um* rot r> * + rot r> * + ;

HB

Re: Optimizing #

<t15s03$avp$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17366&group=comp.lang.forth#17366

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sun, 20 Mar 2022 11:20:19 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t15s03$avp$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t0fjr2$6h3$1@dont-email.me> <t10smb$15d$1@dont-email.me>
<t11c5o$bim$1@gioia.aioe.org> <t123f0$pd5$1@dont-email.me>
<t139kr$13tb$1@gioia.aioe.org>
<c7413ef6-ae02-4abc-878d-43b5ec6e8366n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="11257"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Sun, 20 Mar 2022 00:20 UTC

On 20/03/2022 00:07, Heinrich Hohl wrote:
> On Saturday, March 19, 2022 at 1:54:57 AM UTC+1, dxforth wrote:
>> While most, if not all, systems today use the function in '#' it seems
>> evenly divided whether it's provided as a discrete word to users and
>> under what name.
>
> It seems that the word ud/mod ( ud1 u2 -- urem udquot ) is not needed often.
>
> In the gforth source files (*.fs), it is only used in the number i/o file (nio.fs) in order to
> define #, and in the cross compiler (cross.fs) where it is used to define two words named
> DS! and Sc!
>
> ud/mod itself is defined in kernel.fs
>
> I also searched for the phrase "um/mod r>" but could not find any additional matches.
>
> SwiftForth does not provide a separate word for the UD/MOD routine. This makes the
> related code for # hard to read. In this case I would have preferred a version that
> factors UD/MOD out, even if this word is only used once in the entire system.
> Factoring can improve clarity of code considerably.

Looking further I find FlashForth and AMForth both have UD/MOD. Until now
I wasn't aware of this name being used. Wonder what the history of that was.

While SwiftX doesn't offer such an operator, its # checks to see whether it
needs to do a double division or can get away with a single (at an increase
in code size). Another thing I've not seen before.

Re: Optimizing #

<t15ttk$105f$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17367&group=comp.lang.forth#17367

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sun, 20 Mar 2022 11:53:08 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t15ttk$105f$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t0fjr2$6h3$1@dont-email.me> <t10smb$15d$1@dont-email.me>
<t11c5o$bim$1@gioia.aioe.org> <t123f0$pd5$1@dont-email.me>
<t139kr$13tb$1@gioia.aioe.org>
<c7413ef6-ae02-4abc-878d-43b5ec6e8366n@googlegroups.com>
<9c2b67d1-8ab1-4056-bf33-296ca9400868n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="32943"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sun, 20 Mar 2022 00:53 UTC

On 20/03/2022 00:31, Heinrich Hohl wrote:
> On Saturday, March 19, 2022 at 2:07:31 PM UTC+1, Heinrich Hohl wrote:
>> : D/ ( d1 n+ -- d2) SWAP OVER /MOD >R SWAP UM/MOD SWAP DROP R> ;
>
> Note that PC/FORTH uses floored division. The D/ code shown above will crash ANS systems.
> In ANS compatible systems you can use the following definition:
>
> : D/ ( d1 n+ -- d2) >R S>D R@ FM/MOD R> SWAP >R UM/MOD NIP R> ;
>
> Henry

Thanks. Wonder why it wasn't

: D/MOD ( d1 n+ -- rem d2) >R S>D R@ FM/MOD R> SWAP >R UM/MOD R> ;

which also works AFAIK. A positive modulus being one of the reasons
for using floored division.

Re: Optimizing #

<t169ln$la5$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17368&group=comp.lang.forth#17368

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sun, 20 Mar 2022 15:13:44 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t169ln$la5$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="21829"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sun, 20 Mar 2022 04:13 UTC

On 11/03/2022 23:09, Anton Ertl wrote:
> The folloing description applies to Gforth, but I think that it
> applies to many Forth systems, because this aspect is derived from a
> common ancestor (probably one of Forth, Inc.'s early systems):
>
> The word # (used in, e.g., ".") internally calls UD/MOD, which
> requires two double-by-single divisions:
>
> : ud/mod ( ud1 u2 -- urem udquot ) \ gforth
> \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
> \G quotient @i{udquot} and a single remainder @i{urem}.
> >r 0 r@ um/mod r> swap >r
> um/mod r> ;
>
> : # ( ud1 -- ud2 )
> base @ ud/mod rot dup 9 u>
> [ char A char 9 1+ - ] Literal and +
> '0' + hold ;
>
> Division is slow on many CPUs, and many architectures don't have a
> double-by-single division instruction. So I had the idea that we
> could optimize # by
>
> 1) Dealing with the case where the high word is 0 as a special case.
>
> 2) Dealing with the case where BASE contains #10 as a special case.
> ...

Perhaps already mentioned (tl;dr) but inspired by SwiftX' attempt at 1) ...

A typical definition of # looks something like:

: # ( ud -- ud' )
0 base @ um/mod >r base @ um/mod r>
rot dup 9 > 7 and + hold ;

which invokes UM/MOD twice whether needed or not. At the cost of an 'OVER IF'
it can be reduced to one when high word = 0

: # ( ud -- ud' )
0 over if base @ um/mod then >r base @ um/mod r>
rot dup 9 > 7 and + hold ;

: ud. ( ud -- ) <# #s #> type space ;

-1 -1 cr ud.
-1 0 cr ud.

Re: Optimizing #

<2022Mar20.090729@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17369&group=comp.lang.forth#17369

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sun, 20 Mar 2022 08:07:29 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 66
Message-ID: <2022Mar20.090729@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="53f8d1dc4f582a946a31715650919540";
logging-data="15160"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19IOmoxbjw41oR5JpX0u94r"
Cancel-Lock: sha1:mdGSRkHgl0v18oFAP2tiT8Mzwvs=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 20 Mar 2022 08:07 UTC

dxforth <dxforth@gmail.com> writes:
>On 11/03/2022 23:09, Anton Ertl wrote:
>> The folloing description applies to Gforth, but I think that it
>> applies to many Forth systems, because this aspect is derived from a
>> common ancestor (probably one of Forth, Inc.'s early systems):
>>
>> The word # (used in, e.g., ".") internally calls UD/MOD, which
>> requires two double-by-single divisions:
>>
>> : ud/mod ( ud1 u2 -- urem udquot ) \ gforth
>> \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
>> \G quotient @i{udquot} and a single remainder @i{urem}.
>> >r 0 r@ um/mod r> swap >r
>> um/mod r> ;
>>
>> : # ( ud1 -- ud2 )
>> base @ ud/mod rot dup 9 u>
>> [ char A char 9 1+ - ] Literal and +
>> '0' + hold ;
>>
>> Division is slow on many CPUs, and many architectures don't have a
>> double-by-single division instruction. So I had the idea that we
>> could optimize # by
>>
>> 1) Dealing with the case where the high word is 0 as a special case.
>>
>> 2) Dealing with the case where BASE contains #10 as a special case.
>> ...
>
>Perhaps already mentioned (tl;dr)

It's right behind the stuff you cited.

>A typical definition of # looks something like:
>
> : # ( ud -- ud' )
> 0 base @ um/mod >r base @ um/mod r>
> rot dup 9 > 7 and + hold ;
>
>which invokes UM/MOD twice whether needed or not. At the cost of an 'OVER IF'
>it can be reduced to one when high word = 0
>
> : # ( ud -- ud' )
> 0 over if base @ um/mod then >r base @ um/mod r>
> rot dup 9 > 7 and + hold ;

This invokes um/mod at least once even when the high word=0. Many
architectures have only single-by-single division instructions, and
the solution you snipped is significantly more efficient there:

: # ( ud1 -- ud2 )
?dup-if
base @ ud/mod
else
base @ u/mod 0
then
rot dup 9 u>
[ char A char 9 1+ - ] Literal and +
'0' + hold ;

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Optimizing #

<2022Mar20.095520@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17370&group=comp.lang.forth#17370

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sun, 20 Mar 2022 08:55:20 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 24
Message-ID: <2022Mar20.095520@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="53f8d1dc4f582a946a31715650919540";
logging-data="14821"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xwWJfqqrWE8BLXFVjCepQ"
Cancel-Lock: sha1:pD8IgoznOR934/f+FQGMhVTu0p8=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 20 Mar 2022 08:55 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>Many
>architectures have only single-by-single division instructions, and
[single-by-single U/MOD is more efficient than double-by-single UM/MOD]

Thinking about it, maybe not. The typical way that double-by-single
division is implemented on such architectures is to shift the leading
0s away, perform single-by-single division, then clean up the
imprecision. But that routine itself may special-case the high=0
case. In that case the only cost of using UM/MOD in place of U/MOD is
the additional check for high=0 (which will be perfectly predicted,
because it correlates perfectly with the earlier check). So the cost
may be small.

However, at least __udiv_qrnnd_c() (the generic implementation of
UM/MOD that Gforth falls back to if no more architecture-specific code
is present) does not special-case high=0.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Optimizing #

<t16uhi$4ue$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17371&group=comp.lang.forth#17371

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sun, 20 Mar 2022 21:09:53 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t16uhi$4ue$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="5070"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sun, 20 Mar 2022 10:09 UTC

On 20/03/2022 19:07, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>On 11/03/2022 23:09, Anton Ertl wrote:
>>> The folloing description applies to Gforth, but I think that it
>>> applies to many Forth systems, because this aspect is derived from a
>>> common ancestor (probably one of Forth, Inc.'s early systems):
>>>
>>> The word # (used in, e.g., ".") internally calls UD/MOD, which
>>> requires two double-by-single divisions:
>>>
>>> : ud/mod ( ud1 u2 -- urem udquot ) \ gforth
>>> \G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
>>> \G quotient @i{udquot} and a single remainder @i{urem}.
>>> >r 0 r@ um/mod r> swap >r
>>> um/mod r> ;
>>>
>>> : # ( ud1 -- ud2 )
>>> base @ ud/mod rot dup 9 u>
>>> [ char A char 9 1+ - ] Literal and +
>>> '0' + hold ;
>>>
>>> Division is slow on many CPUs, and many architectures don't have a
>>> double-by-single division instruction. So I had the idea that we
>>> could optimize # by
>>>
>>> 1) Dealing with the case where the high word is 0 as a special case.
>>>
>>> 2) Dealing with the case where BASE contains #10 as a special case.
>>> ...
>>
>>Perhaps already mentioned (tl;dr)
>
> It's right behind the stuff you cited.
>
>>A typical definition of # looks something like:
>>
>> : # ( ud -- ud' )
>> 0 base @ um/mod >r base @ um/mod r>
>> rot dup 9 > 7 and + hold ;
>>
>>which invokes UM/MOD twice whether needed or not. At the cost of an 'OVER IF'
>>it can be reduced to one when high word = 0
>>
>> : # ( ud -- ud' )
>> 0 over if base @ um/mod then >r base @ um/mod r>
>> rot dup 9 > 7 and + hold ;
>
> This invokes um/mod at least once even when the high word=0. Many
> architectures have only single-by-single division instructions, and
> the solution you snipped is significantly more efficient there:
>
> : # ( ud1 -- ud2 )
> ?dup-if
> base @ ud/mod
> else
> base @ u/mod 0
> then
> rot dup 9 u>
> [ char A char 9 1+ - ] Literal and +
> '0' + hold ;

The above tells the reader ud/mod has a problem and should be avoided.
ISTM if there's an opportunity to optimize ud/mod directly that would
be the better option:

: ud/mod ( ud -- urem udquot )
>r 0 over if r@ um/mod then r> swap >r um/mod r> ;

Re: Optimizing #

<2022Mar20.130511@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17373&group=comp.lang.forth#17373

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Sun, 20 Mar 2022 12:05:11 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 39
Message-ID: <2022Mar20.130511@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="53f8d1dc4f582a946a31715650919540";
logging-data="26996"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZKUZVdoVEtzOUHTeZntQL"
Cancel-Lock: sha1:STkMgPhJS6SSBI7rFpSmROdr0Jc=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 20 Mar 2022 12:05 UTC

dxforth <dxforth@gmail.com> writes:
>On 20/03/2022 19:07, Anton Ertl wrote:
>> : # ( ud1 -- ud2 )
>> ?dup-if
>> base @ ud/mod
>> else
>> base @ u/mod 0
>> then
>> rot dup 9 u>
>> [ char A char 9 1+ - ] Literal and +
>> '0' + hold ;
>
>The above tells the reader ud/mod has a problem and should be avoided.

It certainly has a performance problem.

>ISTM if there's an opportunity to optimize ud/mod directly that would
>be the better option:
>
>: ud/mod ( ud -- urem udquot )
> >r 0 over if r@ um/mod then r> swap >r um/mod r> ;

Yes, if we assume that the high=0 case is frequent in general usage of
UD/MOD, it's better to put the special-casing there. But of course
UM/MOD also has performance problems on many architectures, so better
use single-by-single division where possible:

: ud/mod ( ud1 u2 -- urem udquot ) \ gforth
\G divide unsigned double @i{ud1} by @i{u2}, resulting in a unsigned double
\G quotient @i{udquot} and a single remainder @i{urem}.
over 0= if nip u/mod 0 exit then
dup >r u/mod r> swap >r um/mod r> ;

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Optimizing #

<t18d1r$14pn$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17383&group=comp.lang.forth#17383

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Mon, 21 Mar 2022 10:23:37 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t18d1r$14pn$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at>
<t16uhi$4ue$1@gioia.aioe.org> <2022Mar20.130511@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="37687"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Sun, 20 Mar 2022 23:23 UTC

On 20/03/2022 23:05, Anton Ertl wrote:
>
> But of course
> UM/MOD also has performance problems on many architectures, so better
> use single-by-single division where possible:

UM/MOD isn't the problem. It's architectures that only provide single-by-
single division. For the same cycles they could have had double-by-single
as iterations is determined by divisor - not dividend - width.

Re: Optimizing #

<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17384&group=comp.lang.forth#17384

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:89:b0:2e1:b8c7:9975 with SMTP id o9-20020a05622a008900b002e1b8c79975mr14584442qtw.342.1647820128680;
Sun, 20 Mar 2022 16:48:48 -0700 (PDT)
X-Received: by 2002:ad4:5f05:0:b0:440:ea8c:c439 with SMTP id
fo5-20020ad45f05000000b00440ea8cc439mr12987941qvb.69.1647820128456; Sun, 20
Mar 2022 16:48:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 20 Mar 2022 16:48:48 -0700 (PDT)
In-Reply-To: <t18d1r$14pn$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:2a60:9ae:f92c:8b8:6073:9720;
posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 2607:fea8:2a60:9ae:f92c:8b8:6073:9720
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org>
<2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org>
<2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com>
Subject: Re: Optimizing #
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Sun, 20 Mar 2022 23:48:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: Brian Fox - Sun, 20 Mar 2022 23:48 UTC

On Sunday, March 20, 2022 at 7:23:45 PM UTC-4, dxforth wrote:
> On 20/03/2022 23:05, Anton Ertl wrote:
> >
> > But of course
> > UM/MOD also has performance problems on many architectures, so better
> > use single-by-single division where possible:
> UM/MOD isn't the problem. It's architectures that only provide single-by-
> single division. For the same cycles they could have had double-by-single
> as iterations is determined by divisor - not dividend - width.

TMS9900 has double by single division.
But not many care... :-)

BTW
I tested your code to speed up for # in Camel Forth and it was almost a wash.
The tiniest bit of a speed improvement counting 1 to 2000 on the screen.

Re: Optimizing #

<t18gld$8kd$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17385&group=comp.lang.forth#17385

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Mon, 21 Mar 2022 11:25:16 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t18gld$8kd$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at>
<t16uhi$4ue$1@gioia.aioe.org> <2022Mar20.130511@mips.complang.tuwien.ac.at>
<t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="8845"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Mon, 21 Mar 2022 00:25 UTC

On 21/03/2022 10:48, Brian Fox wrote:
> On Sunday, March 20, 2022 at 7:23:45 PM UTC-4, dxforth wrote:
>> On 20/03/2022 23:05, Anton Ertl wrote:
>> >
>> > But of course
>> > UM/MOD also has performance problems on many architectures, so better
>> > use single-by-single division where possible:
>> UM/MOD isn't the problem. It's architectures that only provide single-by-
>> single division. For the same cycles they could have had double-by-single
>> as iterations is determined by divisor - not dividend - width.
>
> TMS9900 has double by single division.
> But not many care... :-)

Were they to use a language that took advantage of mixed-math they
just might care :)

>
> BTW
> I tested your code to speed up for # in Camel Forth and it was almost a wash.
> The tiniest bit of a speed improvement counting 1 to 2000 on the screen.

I've not done any speed tests but given it's possible to hand-code a version
with optimization in less than a machine-coded version without, what's not to
like? :)

see mu/mod
MU/MOD
( 00408ADC 53 ) PUSH EBX
( 00408ADD 8B1C24 ) MOV EBX, [ESP]
( 00408AE0 8B4500 ) MOV EAX, [EBP]
( 00408AE3 BA00000000 ) MOV EDX, 00000000
( 00408AE8 F7F3 ) DIV EBX
( 00408AEA 5B ) POP EBX
( 00408AEB 50 ) PUSH EAX
( 00408AEC 8B4504 ) MOV EAX, [EBP+04]
( 00408AEF F7F3 ) DIV EBX
( 00408AF1 5B ) POP EBX
( 00408AF2 894500 ) MOV [EBP], EAX
( 00408AF5 895504 ) MOV [EBP+04], EDX
( 00408AF8 C3 ) NEXT,
( 29 bytes, 13 instructions )
ok

see ud/mod
UD/MOD
( 004F08A0 8B4500 ) MOV EAX, [EBP]
( 004F08A3 33D2 ) XOR EDX, EDX
( 004F08A5 0BC0 ) OR EAX, EAX
( 004F08A7 7402 ) JZ/E 004F08AB
( 004F08A9 F7F3 ) DIV EBX
( 004F08AB 8BC8 ) MOV ECX, EAX
( 004F08AD 8B4504 ) MOV EAX, [EBP+04]
( 004F08B0 F7F3 ) DIV EBX
( 004F08B2 8BD9 ) MOV EBX, ECX
( 004F08B4 894500 ) MOV [EBP], EAX
( 004F08B7 895504 ) MOV [EBP+04], EDX
( 004F08BA C3 ) NEXT,
( 27 bytes, 12 instructions )
ok

Re: Optimizing #

<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17412&group=comp.lang.forth#17412

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:daa:b0:441:7161:de4b with SMTP id h10-20020a0562140daa00b004417161de4bmr26267118qvh.48.1648601048065;
Tue, 29 Mar 2022 17:44:08 -0700 (PDT)
X-Received: by 2002:ad4:5f05:0:b0:440:ea8c:c439 with SMTP id
fo5-20020ad45f05000000b00440ea8cc439mr29695641qvb.69.1648601047876; Tue, 29
Mar 2022 17:44:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 29 Mar 2022 17:44:07 -0700 (PDT)
In-Reply-To: <t18gld$8kd$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=99.242.210.36; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 99.242.210.36
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org>
<2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org>
<2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com>
Subject: Re: Optimizing #
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Wed, 30 Mar 2022 00:44:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 4
 by: Brian Fox - Wed, 30 Mar 2022 00:44 UTC

It looks like Intel wanted a faster number conversion too.

https://lemire.me/blog/2022/03/28/converting-integers-to-decimal-strings-faster-with-avx-512/

Maybe GForth for Intel could use this new instruction?

Re: Optimizing #

<2022Mar30.093620@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17414&group=comp.lang.forth#17414

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Wed, 30 Mar 2022 07:36:20 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 42
Message-ID: <2022Mar30.093620@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org> <2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org> <e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org> <c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="67748dce196e463e18d3c761a5062237";
logging-data="11635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Pwb4ka31Losq8DfIdB65X"
Cancel-Lock: sha1:DM1R1qHD24W+x7UHk3fgFdATzVI=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 30 Mar 2022 07:36 UTC

Brian Fox <brian.fox@brianfox.ca> writes:
>It looks like Intel wanted a faster number conversion too.
>
>https://lemire.me/blog/2022/03/28/converting-integers-to-decimal-strings-faster-with-avx-512/
>
>Maybe GForth for Intel could use this new instruction?

Why Gforth with its portability goals and not some Intel-specific
Forth system? We do have two IA-32/AMD64-specific optimizations
though: a) we use explicit register allocation for IA-32/AMD64 (gcc's
register allocation has not been good enough for many years; this has
recently changed for AMD64 (I have not checked IA-32); b) we use the
IA-32/AMD64 instructions for um/mod, sm/rem and fm/mod, because you
cannot express double/single division in C.

We are unlikely to use the

1) AVX-512 is not universally available even on recent Intel CPUs, and
Intel is doing everything they can to avoid AVX-512 becoming
universally available. But at least they changed their approach for
AVX/AVX2 now, 11 years after AVX was introduced with Sandy Bridge, 9
years after AVX2 was introduced with Haswell: their most recent
Celeron G CPUs support AVX2 (and I guess this includes AVX), so maybe
in ten years we can consider AVX2 to be universally available.

2) It does not fit in with the existing infrastructure for
number->string conversion.

3) This conversion rarely is a significant contributor to the
execution time.

At least 1) and 2) were not problems for the # optimizations discussed
in this thread, and I was interested in how much benefit they could
buy in the occasional cases where # is a significant contributor, so
3) was not a problem, either.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Optimizing #

<2022Mar30.122149@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17416&group=comp.lang.forth#17416

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Wed, 30 Mar 2022 10:21:49 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 76
Message-ID: <2022Mar30.122149@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org> <2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org> <e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org> <c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at> <25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="67748dce196e463e18d3c761a5062237";
logging-data="19057"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QWRxJPumk/O9PecG9tp1c"
Cancel-Lock: sha1:5zppbiTS6chEDymbeSTa6MiSF9o=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 30 Mar 2022 10:21 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
>> b) we use the=20
>> IA-32/AMD64 instructions for um/mod, sm/rem and fm/mod, because you=20
>> cannot express double/single division in C.=20
>
>Huh? What's wrong with gcc compiling
>
>#include <stdint.h>
>#include <stdio.h>
>
>int main(void) {
>__int128 a=3D10, c;
>int64_t b=3D3;
>c=3Da/b;
>printf("Division : %d",(int)c);
>}

Try it.

For your example, the compiler performs __int128/__int128 division at
compile time, produces the result (__int128)3, converts that it
(int64_t)3 and later (int)3, all at compile time, so in the compiled
code I see

movl $3, %esi

and no division operation of any kind.

A more general example is:

int64_t foo(__int128 a, int64_t b)
{ return a/b;
}

and here's the assembly code that gcc -O3 -S produces:

movq %rdx, %rcx
subq $8, %rsp
sarq $63, %rcx
call __divti3@PLT
addq $8, %rsp
ret

So this sign-extends b into an __int128, and then calls
__int128/__int128 division. Why does gcc do this? Because the C
standard says that both operands have to be converted to a common type
(typically the longer or unsigned type) and then the operation has to
be performed on these types, with a result of that type.

Can a C compiler, knowing that b is in the int64_t range, and that the
result will be converted to int64_t, optimize this division to use
idiv (the signed double/single division instruction)? No, it cannot,
because idiv produces an exception if the result does not fit into a
single machine word, while the compiled C code has to produce an
__int128 result.

The case is different for implementing M* and UM*. You can encode
this in C as

((__int128)a)*b

producing an __int128 result. According to the C standard all
operands have to be converted to __int128, then the operation has to
be performed. However, in this case using the imul instruction for
signed single*single->double multiplication produces the same result
if a and b are originally int64_t, so a C compiler can optimize the C
code to use this instruction, and gcc does that (and has done it for a
long time).

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Optimizing #

<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17417&group=comp.lang.forth#17417

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2946:b0:67b:3047:6d9d with SMTP id n6-20020a05620a294600b0067b30476d9dmr23878755qkp.691.1648643003722;
Wed, 30 Mar 2022 05:23:23 -0700 (PDT)
X-Received: by 2002:a05:620a:1722:b0:67d:8efe:d4e8 with SMTP id
az34-20020a05620a172200b0067d8efed4e8mr23904111qkb.327.1648643003520; Wed, 30
Mar 2022 05:23:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 30 Mar 2022 05:23:23 -0700 (PDT)
In-Reply-To: <2022Mar30.122149@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org>
<2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org>
<2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com> <2022Mar30.122149@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com>
Subject: Re: Optimizing #
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 30 Mar 2022 12:23:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 72
 by: minf...@arcor.de - Wed, 30 Mar 2022 12:23 UTC

Anton Ertl schrieb am Mittwoch, 30. März 2022 um 12:54:08 UTC+2:
> "minf...@arcor.de" <minf...@arcor.de> writes:
> >> b) we use the=20
> >> IA-32/AMD64 instructions for um/mod, sm/rem and fm/mod, because you=20
> >> cannot express double/single division in C.=20
> >
> >Huh? What's wrong with gcc compiling
> >
> >#include <stdint.h>
> >#include <stdio.h>
> >
> >int main(void) {
> >__int128 a=3D10, c;
> >int64_t b=3D3;
> >c=3Da/b;
> >printf("Division : %d",(int)c);
> >}
>
> Try it.
>
> For your example, the compiler performs __int128/__int128 division at
> compile time, produces the result (__int128)3, converts that it
> (int64_t)3 and later (int)3, all at compile time, so in the compiled
> code I see
>
> movl $3, %esi
>
> and no division operation of any kind.
>
> A more general example is:
>
> int64_t foo(__int128 a, int64_t b)
> {
> return a/b;
> }
>
> and here's the assembly code that gcc -O3 -S produces:
>
> movq %rdx, %rcx
> subq $8, %rsp
> sarq $63, %rcx
> call __divti3@PLT
> addq $8, %rsp
> ret
>
> So this sign-extends b into an __int128, and then calls
> __int128/__int128 division. Why does gcc do this? Because the C
> standard says that both operands have to be converted to a common type
> (typically the longer or unsigned type) and then the operation has to
> be performed on these types, with a result of that type.
>
> Can a C compiler, knowing that b is in the int64_t range, and that the
> result will be converted to int64_t, optimize this division to use
> idiv (the signed double/single division instruction)? No, it cannot,
> because idiv produces an exception if the result does not fit into a
> single machine word, while the compiled C code has to produce an
> __int128 result.
>
> The case is different for implementing M* and UM*. You can encode
> this in C as
>
> ((__int128)a)*b
>
> producing an __int128 result. According to the C standard all
> operands have to be converted to __int128, then the operation has to
> be performed. However, in this case using the imul instruction for
> signed single*single->double multiplication produces the same result
> if a and b are originally int64_t, so a C compiler can optimize the C
> code to use this instruction, and gcc does that (and has done it for a
> long time).

Thank you for the good explanations !!!

Re: Optimizing #

<aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17418&group=comp.lang.forth#17418

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:470d:b0:67d:d8a8:68c6 with SMTP id bs13-20020a05620a470d00b0067dd8a868c6mr24447335qkb.717.1648646781859;
Wed, 30 Mar 2022 06:26:21 -0700 (PDT)
X-Received: by 2002:ac8:7f0e:0:b0:2e1:e86f:c73 with SMTP id
f14-20020ac87f0e000000b002e1e86f0c73mr33384336qtk.535.1648646781696; Wed, 30
Mar 2022 06:26:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 30 Mar 2022 06:26:21 -0700 (PDT)
In-Reply-To: <57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org>
<2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org>
<2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com> <2022Mar30.122149@mips.complang.tuwien.ac.at>
<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
Subject: Re: Optimizing #
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 30 Mar 2022 13:26:21 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Hans Bezemer - Wed, 30 Mar 2022 13:26 UTC

On Wednesday, March 30, 2022 at 2:23:24 PM UTC+2, minf...@arcor.de wrote:
> Thank you for the good explanations !!!
I can second that motion - well done, Anton.

However, this is something I always found a weakness in C. Let me begin by saying I don't like compilers doing things behind my back.
Some think that begin able to write:

a := "1" + 1

Is cool. I think it doesn't. As a matter of fact - it makes no sense to me. The most logical thing that I can imagine which happens here
is that "a" contains the address of the "1" string + 1.

This makes as little sense to me:

char a = 15;
long b = 25L;
float c = 0.0;
int d;

d = a + b + c;

The only sensible code IMHO is:

d = (int) a + (int) b + (int) c;

Why? I don't like compilers doing things behind my back, so if not ALL operands are designated the same type - that's an error to me.

It's bad enough operators are overloaded (I like the way Forth thinks), but allowing this leaves to way to much leeway to the compiler
to do whatever it likes. Yes, I know it's all documented - but how many of us are looking in the standard to see whether this thing is
allowed or not - and what the documented behavior of (in this case) C is?

I once had to write my own strtol(), because I found out that under TurboC v2, trap values were converted UNSIGNED - instead of
triggering an error.

So yes - I'm not a big fan of Python or javascript. And I'd rather have a C-- than C++ - where C-- would be a lot dumber and more pedantic
than vanilla C.

Hans Bezemer

Re: Optimizing #

<2022Mar30.184857@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17419&group=comp.lang.forth#17419

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Wed, 30 Mar 2022 16:48:57 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 12
Message-ID: <2022Mar30.184857@mips.complang.tuwien.ac.at>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org> <e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org> <c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at> <25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com> <2022Mar30.122149@mips.complang.tuwien.ac.at> <57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com> <aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="67748dce196e463e18d3c761a5062237";
logging-data="19535"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19viwt4GArxt951IYnw68oo"
Cancel-Lock: sha1:z8Fm7fc2RcF5nTdiusOjaVjgkRA=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 30 Mar 2022 16:48 UTC

Hans Bezemer <the.beez.speaks@gmail.com> writes:
>And I'd rather have a C-- than C++ - where C-- would be a lot dumber and more pedantic
>than vanilla C.

Maybe Rust is to your taste.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Optimizing #

<t22qkl$1sbd$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17420&group=comp.lang.forth#17420

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Thu, 31 Mar 2022 10:55:01 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t22qkl$1sbd$1@gioia.aioe.org>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t169ln$la5$1@gioia.aioe.org> <2022Mar20.090729@mips.complang.tuwien.ac.at>
<t16uhi$4ue$1@gioia.aioe.org> <2022Mar20.130511@mips.complang.tuwien.ac.at>
<t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com>
<t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com>
<2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com>
<2022Mar30.122149@mips.complang.tuwien.ac.at>
<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com>
<aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="61805"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Wed, 30 Mar 2022 23:55 UTC

On 31/03/2022 00:26, Hans Bezemer wrote:
>
> Why? I don't like compilers doing things behind my back, so if not ALL operands are designated the same type - that's an error to me.
>
> It's bad enough operators are overloaded (I like the way Forth thinks), but allowing this leaves to way to much leeway to the compiler
> to do whatever it likes. Yes, I know it's all documented - but how many of us are looking in the standard to see whether this thing is
> allowed or not - and what the documented behavior of (in this case) C is?
>
> I once had to write my own strtol(), because I found out that under TurboC v2, trap values were converted UNSIGNED - instead of
> triggering an error.
>
> So yes - I'm not a big fan of Python or javascript. And I'd rather have a C-- than C++ - where C-- would be a lot dumber and more pedantic
> than vanilla C.

Are you trying to put compiler writers out of business? But no fear of that.
Who can resist when the Serpent whispers 'All these things I can give you'.

Re: Optimizing #

<0e0b2345-ad9d-4d6b-8ec8-f3a01a8cd59en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17421&group=comp.lang.forth#17421

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:14c8:b0:2e1:d626:66ea with SMTP id u8-20020a05622a14c800b002e1d62666eamr3301036qtx.58.1648716802972;
Thu, 31 Mar 2022 01:53:22 -0700 (PDT)
X-Received: by 2002:a05:6214:1cc5:b0:443:6a15:5894 with SMTP id
g5-20020a0562141cc500b004436a155894mr3049101qvd.59.1648716802809; Thu, 31 Mar
2022 01:53:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 31 Mar 2022 01:53:22 -0700 (PDT)
In-Reply-To: <2022Mar30.184857@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com> <2022Mar30.122149@mips.complang.tuwien.ac.at>
<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com> <aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
<2022Mar30.184857@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0e0b2345-ad9d-4d6b-8ec8-f3a01a8cd59en@googlegroups.com>
Subject: Re: Optimizing #
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Thu, 31 Mar 2022 08:53:22 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: Hans Bezemer - Thu, 31 Mar 2022 08:53 UTC

On Wednesday, March 30, 2022 at 6:51:46 PM UTC+2, Anton Ertl wrote:
> Hans Bezemer <the.bee...@gmail.com> writes:
> >And I'd rather have a C-- than C++ - where C-- would be a lot dumber and more pedantic
> >than vanilla C.
> Maybe Rust is to your taste.
> - anton
> --
> M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> New standard: http://www.forth200x.org/forth200x.html
> EuroForth 2021: https://euro.theforth.net/2021
Rust is as much removed from portable assembly as a microbe is removed from a fighter pilot.
Not to mention its butt ugly syntax. What I want is an unabstracted language - not an overly
abstracted one. It's just nice to know when you're doing something stupid - something that simply
doesn't compile. Like adding an integer to a float.

HB

Re: Optimizing #

<35993ddb-8d17-4483-b3c5-4819e172d2fdn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17422&group=comp.lang.forth#17422

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7d91:0:b0:2e0:6b65:c76c with SMTP id c17-20020ac87d91000000b002e06b65c76cmr3305124qtd.564.1648718296075;
Thu, 31 Mar 2022 02:18:16 -0700 (PDT)
X-Received: by 2002:a05:620a:3cc:b0:67b:e77:6f21 with SMTP id
r12-20020a05620a03cc00b0067b0e776f21mr2648122qkm.272.1648718295923; Thu, 31
Mar 2022 02:18:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 31 Mar 2022 02:18:15 -0700 (PDT)
In-Reply-To: <t22qkl$1sbd$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org>
<2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org>
<2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com> <2022Mar30.122149@mips.complang.tuwien.ac.at>
<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com> <aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
<t22qkl$1sbd$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <35993ddb-8d17-4483-b3c5-4819e172d2fdn@googlegroups.com>
Subject: Re: Optimizing #
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Thu, 31 Mar 2022 09:18:16 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 22
 by: Hans Bezemer - Thu, 31 Mar 2022 09:18 UTC

On Thursday, March 31, 2022 at 1:55:06 AM UTC+2, dxforth wrote:
> On 31/03/2022 00:26, Hans Bezemer wrote:
> >
> > Why? I don't like compilers doing things behind my back, so if not ALL operands are designated the same type - that's an error to me.
> >
> > It's bad enough operators are overloaded (I like the way Forth thinks), but allowing this leaves to way to much leeway to the compiler
> > to do whatever it likes. Yes, I know it's all documented - but how many of us are looking in the standard to see whether this thing is
> > allowed or not - and what the documented behavior of (in this case) C is?
> >
> > I once had to write my own strtol(), because I found out that under TurboC v2, trap values were converted UNSIGNED - instead of
> > triggering an error.
> >
> > So yes - I'm not a big fan of Python or javascript. And I'd rather have a C-- than C++ - where C-- would be a lot dumber and more pedantic
> > than vanilla C.
> Are you trying to put compiler writers out of business? But no fear of that.
> Who can resist when the Serpent whispers 'All these things I can give you'.

Yeah - but I'm not biting. Best thing so far is still C. Although I'm quite worried about the developments there.
If those continue I fear what I have to do to keep my compiler running predictably.

And since I like it to be running on every platform, any niche or fringe language will not do.

Hans Bezemer

Re: Optimizing #

<46d59625-7758-420f-bcd9-60c6e5ae7078n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17428&group=comp.lang.forth#17428

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:f50b:0:b0:680:d577:baf6 with SMTP id l11-20020a37f50b000000b00680d577baf6mr3567590qkk.328.1648736914303;
Thu, 31 Mar 2022 07:28:34 -0700 (PDT)
X-Received: by 2002:ad4:5f05:0:b0:440:ea8c:c439 with SMTP id
fo5-20020ad45f05000000b00440ea8cc439mr4296739qvb.69.1648736914137; Thu, 31
Mar 2022 07:28:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 31 Mar 2022 07:28:34 -0700 (PDT)
In-Reply-To: <35993ddb-8d17-4483-b3c5-4819e172d2fdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t169ln$la5$1@gioia.aioe.org>
<2022Mar20.090729@mips.complang.tuwien.ac.at> <t16uhi$4ue$1@gioia.aioe.org>
<2022Mar20.130511@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com> <2022Mar30.122149@mips.complang.tuwien.ac.at>
<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com> <aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
<t22qkl$1sbd$1@gioia.aioe.org> <35993ddb-8d17-4483-b3c5-4819e172d2fdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <46d59625-7758-420f-bcd9-60c6e5ae7078n@googlegroups.com>
Subject: Re: Optimizing #
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Thu, 31 Mar 2022 14:28:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: minf...@arcor.de - Thu, 31 Mar 2022 14:28 UTC

the.bee...@gmail.com schrieb am Donnerstag, 31. März 2022 um 11:18:17 UTC+2:
> On Thursday, March 31, 2022 at 1:55:06 AM UTC+2, dxforth wrote:
> > On 31/03/2022 00:26, Hans Bezemer wrote:
> > >
> > > Why? I don't like compilers doing things behind my back, so if not ALL operands are designated the same type - that's an error to me.
> > >
> > > It's bad enough operators are overloaded (I like the way Forth thinks), but allowing this leaves to way to much leeway to the compiler
> > > to do whatever it likes. Yes, I know it's all documented - but how many of us are looking in the standard to see whether this thing is
> > > allowed or not - and what the documented behavior of (in this case) C is?
> > >
> > > I once had to write my own strtol(), because I found out that under TurboC v2, trap values were converted UNSIGNED - instead of
> > > triggering an error.
> > >
> > > So yes - I'm not a big fan of Python or javascript. And I'd rather have a C-- than C++ - where C-- would be a lot dumber and more pedantic
> > > than vanilla C.
> > Are you trying to put compiler writers out of business? But no fear of that.
> > Who can resist when the Serpent whispers 'All these things I can give you'.
> Yeah - but I'm not biting. Best thing so far is still C. Although I'm quite worried about the developments there.
> If those continue I fear what I have to do to keep my compiler running predictably.
>
> And since I like it to be running on every platform, any niche or fringe language will not do.
>

AFAIK your 4th is more geared for desktops than for microcontrollers
(I may be wrong here). There AMD64 assembly covers 90% of the "market"
and is no niche language.

Re: Optimizing #

<87zgl5fwfc.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17432&group=comp.lang.forth#17432

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Optimizing #
Date: Thu, 31 Mar 2022 18:02:15 -0700
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <87zgl5fwfc.fsf@nightsong.com>
References: <2022Mar11.130937@mips.complang.tuwien.ac.at>
<t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com>
<t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com>
<2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com>
<2022Mar30.122149@mips.complang.tuwien.ac.at>
<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com>
<aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
<2022Mar30.184857@mips.complang.tuwien.ac.at>
<0e0b2345-ad9d-4d6b-8ec8-f3a01a8cd59en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="b0ba950e05ee330e1d8d5e097cad97ac";
logging-data="29516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1R2xs2lwBcyIIFawRMLAi"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:0pnhdZPsLJ59Ffsekx41Ma9ZJU4=
sha1:iLA3+iS3/ZigMAT+rYHn+PADONg=
 by: Paul Rubin - Fri, 1 Apr 2022 01:02 UTC

Hans Bezemer <the.beez.speaks@gmail.com> writes:
> It's just nice to know when you're doing something stupid - something
> that simply doesn't compile. Like adding an integer to a float.

Those automatic conversions seem to have gone out of style in recent
decades, and a good thing too. I guess you don't like Ada though.

Re: Optimizing #

<c47e7b65-2c6f-47f6-bfa9-fa989f3cc200n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17433&group=comp.lang.forth#17433

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:21d4:b0:67d:6a35:5dff with SMTP id h20-20020a05620a21d400b0067d6a355dffmr5682119qka.747.1648797024145;
Fri, 01 Apr 2022 00:10:24 -0700 (PDT)
X-Received: by 2002:a05:620a:31a0:b0:67d:7500:1752 with SMTP id
bi32-20020a05620a31a000b0067d75001752mr5764346qkb.485.1648797024002; Fri, 01
Apr 2022 00:10:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 1 Apr 2022 00:10:23 -0700 (PDT)
In-Reply-To: <87zgl5fwfc.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=176.74.235.101; posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 176.74.235.101
References: <2022Mar11.130937@mips.complang.tuwien.ac.at> <t18d1r$14pn$1@gioia.aioe.org>
<e913832b-2db5-4341-84e6-49a367d48ca3n@googlegroups.com> <t18gld$8kd$1@gioia.aioe.org>
<c668c0f6-4734-4158-a714-c8fc75de30d9n@googlegroups.com> <2022Mar30.093620@mips.complang.tuwien.ac.at>
<25972ba2-4b0d-4b74-8e06-7a2639efff57n@googlegroups.com> <2022Mar30.122149@mips.complang.tuwien.ac.at>
<57e234fc-a492-4ea5-97c2-7d3d26e77977n@googlegroups.com> <aeb6fa41-f62d-43a5-b80b-590ce0d14ae9n@googlegroups.com>
<2022Mar30.184857@mips.complang.tuwien.ac.at> <0e0b2345-ad9d-4d6b-8ec8-f3a01a8cd59en@googlegroups.com>
<87zgl5fwfc.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c47e7b65-2c6f-47f6-bfa9-fa989f3cc200n@googlegroups.com>
Subject: Re: Optimizing #
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Fri, 01 Apr 2022 07:10:24 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Marcel Hendrix - Fri, 1 Apr 2022 07:10 UTC

On Friday, April 1, 2022 at 3:02:18 AM UTC+2, Paul Rubin wrote:
> Hans Bezemer <the.bee...@gmail.com> writes:
> > It's just nice to know when you're doing something stupid - something
> > that simply doesn't compile. Like adding an integer to a float.
> Those automatic conversions seem to have gone out of style in recent
> decades, and a good thing too. I guess you don't like Ada though.

I would be worried more about adding a float to an integer.

-marcel

Pages:1234
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor