Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

...and scantily clad females, of course. Who cares if it's below zero outside. -- Linus Torvalds


devel / comp.arch / Re: Compact representation for common integer constants

SubjectAuthor
* Compact representation for common integer constantsJohnG
+* Re: Compact representation for common integer constantsIvan Godard
|+- Re: Compact representation for common integer constantsDavid Brown
|`* Re: Compact representation for common integer constantsJohnG
| `* Re: Compact representation for common integer constantsBGB
|  `* Re: Compact representation for common integer constantsMitchAlsup
|   `* Re: Compact representation for common integer constantsBGB
|    `* Re: Compact representation for common integer constantsThomas Koenig
|     +- Re: Compact representation for common integer constantsMitchAlsup
|     `* Re: Compact representation for common integer constantsBGB
|      `* Re: Compact representation for common integer constantsMitchAlsup
|       `* Re: Compact representation for common integer constantsIvan Godard
|        +- Re: Compact representation for common integer constantsMarcus
|        +* Re: Compact representation for common integer constantsBGB
|        |`* Re: Compact representation for common integer constantsMitchAlsup
|        | +* Clamping. was: Compact representation for common integer constantsIvan Godard
|        | |+* Re: Clamping. was: Compact representation for common integer constantsMitchAlsup
|        | ||`* Re: Clamping. was: Compact representation for common integerIvan Godard
|        | || `- Re: Clamping. was: Compact representation for common integer constantsMitchAlsup
|        | |`* Re: Clamping. was: Compact representation for common integerBGB
|        | | `* Re: Clamping. was: Compact representation for common integerIvan Godard
|        | |  `- Re: Clamping. was: Compact representation for common integer constantsMitchAlsup
|        | +* Re: Compact representation for common integer constantsMarcus
|        | |`* Re: Compact representation for common integer constantsMitchAlsup
|        | | `* Re: Compact representation for common integer constantsDavid Brown
|        | |  `* Re: Compact representation for common integer constantsMitchAlsup
|        | |   +- Re: Compact representation for common integer constantsThomas Koenig
|        | |   `* Re: Compact representation for common integer constantsDavid Brown
|        | |    `- Re: Compact representation for common integer constantsMitchAlsup
|        | `* Re: Compact representation for common integer constantsThomas Koenig
|        |  +- Re: Compact representation for common integer constantsAnton Ertl
|        |  `* Re: Compact representation for common integer constantsMitchAlsup
|        |   `* Re: Compact representation for common integer constantsThomas Koenig
|        |    +* Re: Compact representation for common integer constantsAnton Ertl
|        |    |`* Re: Compact representation for common integer constantsBrian G. Lucas
|        |    | +* Re: Compact representation for common integer constantsThomas Koenig
|        |    | |`- Re: Compact representation for common integer constantsBrian G. Lucas
|        |    | +- Re: Compact representation for common integer constantsStefan Monnier
|        |    | `* Re: Compact representation for common integer constantsAnton Ertl
|        |    |  `* Re: Compact representation for common integer constantsThomas Koenig
|        |    |   +* Re: Compact representation for common integer constantsAnton Ertl
|        |    |   |`* Re: Compact representation for common integer constantsThomas Koenig
|        |    |   | `- Re: Compact representation for common integer constantsAnton Ertl
|        |    |   `* Re: Compact representation for common integer constantsTerje Mathisen
|        |    |    `- Re: Compact representation for common integer constantsAnton Ertl
|        |    `* Re: Compact representation for common integer constantsMitchAlsup
|        |     `* Re: Compact representation for common integer constantsThomas Koenig
|        |      `* Re: Compact representation for common integer constantsBrian G. Lucas
|        |       `* Re: Compact representation for common integer constantsThomas Koenig
|        |        +* Re: Compact representation for common integer constantsMitchAlsup
|        |        |`- Re: Compact representation for common integer constantsThomas Koenig
|        |        +* Re: Compact representation for common integer constantsAnton Ertl
|        |        |+* Re: Compact representation for common integer constantsThomas Koenig
|        |        ||+* Re: Compact representation for common integer constantsMitchAlsup
|        |        |||`* Re: Compact representation for common integer constantsThomas Koenig
|        |        ||| `- Re: Compact representation for common integer constantsMitchAlsup
|        |        ||`* Re: Compact representation for common integer constantsAnton Ertl
|        |        || +* Re: Compact representation for common integer constantsMitchAlsup
|        |        || |+* Re: Compact representation for common integer constantsEricP
|        |        || ||+* Re: Compact representation for common integer constantsThomas Koenig
|        |        || |||+- Re: Compact representation for common integer constantsMitchAlsup
|        |        || |||+* Re: Compact representation for common integer constantsEricP
|        |        || ||||`* Re: Compact representation for common integer constantsTerje Mathisen
|        |        || |||| `* Re: Compact representation for common integer constantsDavid Brown
|        |        || ||||  `* Re: Compact representation for common integer constantsTerje Mathisen
|        |        || ||||   `* Re: Compact representation for common integer constantsDavid Brown
|        |        || ||||    `- Re: Compact representation for common integer constantsTerje Mathisen
|        |        || |||`* Re: Compact representation for common integer constantsStephen Fuld
|        |        || ||| `* Re: Compact representation for common integer constantsMitchAlsup
|        |        || |||  +- Re: Compact representation for common integer constantsStephen Fuld
|        |        || |||  `* Re: Compact representation for common integer constantsBill Findlay
|        |        || |||   `* Re: Compact representation for common integer constantsMitchAlsup
|        |        || |||    `- Re: Compact representation for common integer constantsBill Findlay
|        |        || ||+* Re: Compact representation for common integer constantsThomas Koenig
|        |        || |||+* Re: Compact representation for common integer constantsStephen Fuld
|        |        || ||||`- Re: Compact representation for common integer constantsThomas Koenig
|        |        || |||`- Re: Compact representation for common integer constantsEricP
|        |        || ||`* Re: Compact representation for common integer constantsStephen Fuld
|        |        || || +* Re: Compact representation for common integer constantsNiklas Holsti
|        |        || || |`* Re: Compact representation for common integer constantsStephen Fuld
|        |        || || | `* Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |  `* Re: Compact representation for common integer constantsStephen Fuld
|        |        || || |   `* Re: Compact representation for common integer constantsEricP
|        |        || || |    +* Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |    |`* Re: Compact representation for common integer constantsEricP
|        |        || || |    | `* Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |    |  `* Re: Compact representation for common integer constantsThomas Koenig
|        |        || || |    |   +- Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |    |   `* Re: Compact representation for common integer constantsTerje Mathisen
|        |        || || |    |    `* Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |    |     +- Re: Compact representation for common integer constantsTerje Mathisen
|        |        || || |    |     `* Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |    |      `- Re: Compact representation for common integer constantsTerje Mathisen
|        |        || || |    `* Re: Compact representation for common integer constantsStephen Fuld
|        |        || || |     `* Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |      +- Re: Compact representation for common integer constantsBill Findlay
|        |        || || |      +* Re: Compact representation for common integer constantsThomas Koenig
|        |        || || |      |+* Re: Compact representation for common integer constantsAnton Ertl
|        |        || || |      ||`* Re: Compact representation for common integer constantsThomas Koenig
|        |        || || |      || `- Re: Compact representation for common integer constantsAnton Ertl
|        |        || || |      |`* Re: Compact representation for common integer constantsMitchAlsup
|        |        || || |      +* Re: Compact representation for common integer constantsTerje Mathisen
|        |        || || |      `* Re: Compact representation for common integer constantsStephen Fuld
|        |        || || `* Re: Compact representation for common integer constantsEricP
|        |        || |`- Re: Compact representation for common integer constantsAnton Ertl
|        |        || `* Re: Compact representation for common integer constantsThomas Koenig
|        |        |`* Re: Compact representation for common integer constantsMitchAlsup
|        |        `* Re: Compact representation for common integer constantsBrian G. Lucas
|        `* Re: Compact representation for common integer constantsQuadibloc
+* Re: Compact representation for common integer constantsBGB
`* Re: Compact representation for common integer constantsJohn Levine

Pages:123456789101112131415
Re: Compact representation for common integer constants

<5fd52997-024d-4a50-87a1-3dbaa1827899n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17254&group=comp.arch#17254

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:9e4c:: with SMTP id h73mr9319207qke.68.1622311002265; Sat, 29 May 2021 10:56:42 -0700 (PDT)
X-Received: by 2002:a4a:d809:: with SMTP id f9mr5158453oov.71.1622311002067; Sat, 29 May 2021 10:56:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!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.arch
Date: Sat, 29 May 2021 10:56:41 -0700 (PDT)
In-Reply-To: <s8riid$vba$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.183.172; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.183.172
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com> <2021May19.124934@mips.complang.tuwien.ac.at> <d5edb86e-0166-4c44-83eb-19e1cd8eb2c4n@googlegroups.com> <nqapI.385883$2A5.264183@fx45.iad> <s84b5i$mal$1@dont-email.me> <igmeioFr49pU1@mid.individual.net> <s85u1e$2nb$1@dont-email.me> <51fddd24-666f-4914-9161-30e010e0ef92n@googlegroups.com> <s864if$mqg$1@dont-email.me> <q1UpI.60399$DZ5.42895@fx23.iad> <s89ahe$t4n$1@dont-email.me> <26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com> <s8lqsr$aru$1@dont-email.me> <88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com> <s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org> <s8nd5j$bas$1@dont-email.me> <s8ne5m$g8d$1@dont-email.me> <s8nqlb$160s$1@gioia.aioe.org> <s8nt68$ond$1@newsreader4.netcologne.de> <s8o945$62e$1@gioia.aioe.org> <s8oj0e$4b1$1@newsreader4.netcologne.de> <s8oudj$frs$1@gioia.aioe.org> <s8q19m$1ar$1@newsreader4.netcologne.de> <s8q6n5$1hv5$1@gioia.aioe.org> <s8r2ln$hrv$1@newsreader4.netcologne.de> <s8riid$vba$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5fd52997-024d-4a50-87a1-3dbaa1827899n@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: already5...@yahoo.com (Michael S)
Injection-Date: Sat, 29 May 2021 17:56:42 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: Michael S - Sat, 29 May 2021 17:56 UTC

On Friday, May 28, 2021 at 11:07:47 PM UTC+3, Terje Mathisen wrote:
> Thomas Koenig wrote:
> > Terje Mathisen <terje.m...@tmsw.no> schrieb:
> >
> >> I see you already figured this out, but I'm still posting to illustrate
> >> that it is hard to do long chain carry propagation without having the
> >> moral equivalent of ADC.
> >
> > I just browsed around a bit, and I found that, on x86 at least, you
> > can use _addcarryx_u64.
> Right, this was the intrinsic I used for both of my 128 and 256-bit
> examples.

But why?
Both of your examples should work fine with plain old _addcarry_u64 ()
Or am I missing something?

> >
> > clang gets this right: https://gcc.godbolt.org/z/b9dTn8aWj
> > whereas gcc currently does not, as you can see in
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79173 .
> >
> clang is very swiftly leaving gcc well behind for all new development.
> Terje
>
> --
> - <Terje.Mathisen at tmsw.no>
> "almost all programming can be viewed as an exercise in caching"

Re: Compact representation for common integer constants

<memo.20210529185824.13680D@jgd.cix.co.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17255&group=comp.arch#17255

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jgd...@cix.co.uk (John Dallman)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Sat, 29 May 2021 18:58 +0100 (BST)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <memo.20210529185824.13680D@jgd.cix.co.uk>
References: <2021May29.184428@mips.complang.tuwien.ac.at>
Reply-To: jgd@cix.co.uk
Injection-Info: reader02.eternal-september.org; posting-host="f10b2b34770732b7eddf1b1e324a3136";
logging-data="31757"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CuSXZqT/8I7y7Pivzg00rYJvKALqyROo="
Cancel-Lock: sha1:SEA5i65qf0zC0V8To+LfeTJNldQ=
 by: John Dallman - Sat, 29 May 2021 17:58 UTC

In article <2021May29.184428@mips.complang.tuwien.ac.at>,
anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:

> It looks to me like this C++ ABI is based on the regular ABI (C and
> Fortran features), and defines various C++ things in terms of that,
> and that's why it can transcend individual architectures.

That's correct. The Itanium required some systematic thinking about
calling conventions and ABIs, which is why the name stuck to the new
convention.

I had to change a lot of stuff in an extensible printf implementation to
support Itanium, but that also fixed problems I had on MIPS. Upgrading it
for other architectures since then since then has been comparatively
simple.

John

Re: Compact representation for common integer constants

<s8tvs3$112k$2@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17257&group=comp.arch#17257

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!/FKOcGQMirZgkZJCo9x3IA.user.gioia.aioe.org.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Sat, 29 May 2021 20:07:00 +0200
Organization: Aioe.org NNTP Server
Lines: 33
Message-ID: <s8tvs3$112k$2@gioia.aioe.org>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<nqapI.385883$2A5.264183@fx45.iad> <s84b5i$mal$1@dont-email.me>
<igmeioFr49pU1@mid.individual.net> <s85u1e$2nb$1@dont-email.me>
<51fddd24-666f-4914-9161-30e010e0ef92n@googlegroups.com>
<s864if$mqg$1@dont-email.me> <q1UpI.60399$DZ5.42895@fx23.iad>
<s89ahe$t4n$1@dont-email.me>
<26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com>
<s8lqsr$aru$1@dont-email.me>
<88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com>
<s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org>
<s8nd5j$bas$1@dont-email.me> <s8ne5m$g8d$1@dont-email.me>
<s8nqlb$160s$1@gioia.aioe.org> <s8nt68$ond$1@newsreader4.netcologne.de>
<s8o945$62e$1@gioia.aioe.org> <s8oj0e$4b1$1@newsreader4.netcologne.de>
<s8oudj$frs$1@gioia.aioe.org> <s8q19m$1ar$1@newsreader4.netcologne.de>
<s8q6n5$1hv5$1@gioia.aioe.org> <s8r2ln$hrv$1@newsreader4.netcologne.de>
<s8riid$vba$1@gioia.aioe.org>
<fb4441b4-bc4a-4382-a137-92eb2c1b2504n@googlegroups.com>
NNTP-Posting-Host: /FKOcGQMirZgkZJCo9x3IA.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.7
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Sat, 29 May 2021 18:07 UTC

MitchAlsup wrote:
> On Friday, May 28, 2021 at 3:07:47 PM UTC-5, Terje Mathisen wrote:
>> Thomas Koenig wrote:
>>> Terje Mathisen <terje.m...@tmsw.no> schrieb:
>>>
>>>> I see you already figured this out, but I'm still posting to illustrate
>>>> that it is hard to do long chain carry propagation without having the
>>>> moral equivalent of ADC.
>>>
>>> I just browsed around a bit, and I found that, on x86 at least, you
>>> can use _addcarryx_u64.
>> Right, this was the intrinsic I used for both of my 128 and 256-bit
>> examples.
>>>
>>> clang gets this right: https://gcc.godbolt.org/z/b9dTn8aWj
>>> whereas gcc currently does not, as you can see in
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79173 .
>>>
>> clang is very swiftly leaving gcc well behind for all new development.
> <
> Is that because GCC has grown into an impossible monster,
> ....that because GCC licensing requirements
> or that more people have jumped onto clang
> ....that clang is easier to develop ??

Maybe "all of the above?"

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Compact representation for common integer constants

<fe2427fe-34bc-a4ca-b4ff-a064b18fbabe@tmsw.no>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17258&group=comp.arch#17258

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!/FKOcGQMirZgkZJCo9x3IA.user.gioia.aioe.org.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Sat, 29 May 2021 20:17:50 +0200
Organization: Aioe.org NNTP Server
Lines: 43
Message-ID: <fe2427fe-34bc-a4ca-b4ff-a064b18fbabe@tmsw.no>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<nqapI.385883$2A5.264183@fx45.iad> <s84b5i$mal$1@dont-email.me>
<igmeioFr49pU1@mid.individual.net> <s85u1e$2nb$1@dont-email.me>
<51fddd24-666f-4914-9161-30e010e0ef92n@googlegroups.com>
<s864if$mqg$1@dont-email.me> <q1UpI.60399$DZ5.42895@fx23.iad>
<s89ahe$t4n$1@dont-email.me>
<26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com>
<s8lqsr$aru$1@dont-email.me>
<88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com>
<s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org>
<s8nd5j$bas$1@dont-email.me> <s8ne5m$g8d$1@dont-email.me>
<s8nqlb$160s$1@gioia.aioe.org> <s8nt68$ond$1@newsreader4.netcologne.de>
<s8o945$62e$1@gioia.aioe.org> <s8oj0e$4b1$1@newsreader4.netcologne.de>
<s8oudj$frs$1@gioia.aioe.org> <s8q19m$1ar$1@newsreader4.netcologne.de>
<s8q6n5$1hv5$1@gioia.aioe.org> <s8r2ln$hrv$1@newsreader4.netcologne.de>
<s8riid$vba$1@gioia.aioe.org>
<5fd52997-024d-4a50-87a1-3dbaa1827899n@googlegroups.com>
NNTP-Posting-Host: /FKOcGQMirZgkZJCo9x3IA.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.7
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Sat, 29 May 2021 18:17 UTC

Michael S wrote:
> On Friday, May 28, 2021 at 11:07:47 PM UTC+3, Terje Mathisen wrote:
>> Thomas Koenig wrote:
>>> Terje Mathisen <terje.m...@tmsw.no> schrieb:
>>>
>>>> I see you already figured this out, but I'm still posting to illustrate
>>>> that it is hard to do long chain carry propagation without having the
>>>> moral equivalent of ADC.
>>>
>>> I just browsed around a bit, and I found that, on x86 at least, you
>>> can use _addcarryx_u64.
>> Right, this was the intrinsic I used for both of my 128 and 256-bit
>> examples.
>
> But why?
> Both of your examples should work fine with plain old _addcarry_u64 ()
> Or am I missing something?

Not really:

This is just me that consider these two instrinsics to effectively be
the same, and I suspect that some (most?) compielrs that support them
will in fact generate effectively the same code for both.

The main differentiator is probably that on a very old CPU, using the
'x' version would fail because the new carry/overflow instruction are
unsupported.

IMHO, it will be extremely rare to see production code using the new
instructions to generate two carry chains simultaneously, since they
effectively (modulo the JRCXZ trick I posted a couple of days ago)
cannot be used in loops, only in short unrolled code blocks.

When you only need one chain of limited length, then plain old
ADD/ADC/ADC/ADC... works perfectly well. Using only the new carry-based
instruction makes it easier to create relatively normal loops since you
can combine ADCX with LOOP.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Compact representation for common integer constants

<5f45373a-6bad-4f8f-876f-47ba8f53eb0bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17259&group=comp.arch#17259

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:902:: with SMTP id dj2mr9672252qvb.11.1622313690047; Sat, 29 May 2021 11:41:30 -0700 (PDT)
X-Received: by 2002:a05:6808:1496:: with SMTP id e22mr10259202oiw.78.1622313689695; Sat, 29 May 2021 11:41:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!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.arch
Date: Sat, 29 May 2021 11:41:29 -0700 (PDT)
In-Reply-To: <fe2427fe-34bc-a4ca-b4ff-a064b18fbabe@tmsw.no>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.183.172; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.183.172
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com> <nqapI.385883$2A5.264183@fx45.iad> <s84b5i$mal$1@dont-email.me> <igmeioFr49pU1@mid.individual.net> <s85u1e$2nb$1@dont-email.me> <51fddd24-666f-4914-9161-30e010e0ef92n@googlegroups.com> <s864if$mqg$1@dont-email.me> <q1UpI.60399$DZ5.42895@fx23.iad> <s89ahe$t4n$1@dont-email.me> <26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com> <s8lqsr$aru$1@dont-email.me> <88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com> <s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org> <s8nd5j$bas$1@dont-email.me> <s8ne5m$g8d$1@dont-email.me> <s8nqlb$160s$1@gioia.aioe.org> <s8nt68$ond$1@newsreader4.netcologne.de> <s8o945$62e$1@gioia.aioe.org> <s8oj0e$4b1$1@newsreader4.netcologne.de> <s8oudj$frs$1@gioia.aioe.org> <s8q19m$1ar$1@newsreader4.netcologne.de> <s8q6n5$1hv5$1@gioia.aioe.org> <s8r2ln$hrv$1@newsreader4.netcologne.de> <s8riid$vba$1@gioia.aioe.org> <5fd52997-024d-4a50-87a1-3dbaa1827899n@googlegroups.com> <fe2427fe-34bc-a4ca-b4ff-a064b18fbabe@tmsw.no>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5f45373a-6bad-4f8f-876f-47ba8f53eb0bn@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: already5...@yahoo.com (Michael S)
Injection-Date: Sat, 29 May 2021 18:41:30 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 49
 by: Michael S - Sat, 29 May 2021 18:41 UTC

On Saturday, May 29, 2021 at 9:17:52 PM UTC+3, Terje Mathisen wrote:
> Michael S wrote:
> > On Friday, May 28, 2021 at 11:07:47 PM UTC+3, Terje Mathisen wrote:
> >> Thomas Koenig wrote:
> >>> Terje Mathisen <terje.m...@tmsw.no> schrieb:
> >>>
> >>>> I see you already figured this out, but I'm still posting to illustrate
> >>>> that it is hard to do long chain carry propagation without having the
> >>>> moral equivalent of ADC.
> >>>
> >>> I just browsed around a bit, and I found that, on x86 at least, you
> >>> can use _addcarryx_u64.
> >> Right, this was the intrinsic I used for both of my 128 and 256-bit
> >> examples.
> >
> > But why?
> > Both of your examples should work fine with plain old _addcarry_u64 ()
> > Or am I missing something?
> Not really:
>
> This is just me that consider these two instrinsics to effectively be
> the same, and I suspect that some (most?) compielrs that support them
> will in fact generate effectively the same code for both.
>
> The main differentiator is probably that on a very old CPU,

Both my main home desktop and my main work desktop. Both Ivy Bridge.
By single-threaded non-vector performance they, esp. the work desktop, are still less than twice slower than the latest greatest Zen3.

And there exist much newer CPUs that do not support ADX. Like Haswell.
Or Tremont that was launched last year.

> using the
> 'x' version would fail because the new carry/overflow instruction are
> unsupported.
>
> IMHO, it will be extremely rare to see production code using the new
> instructions to generate two carry chains simultaneously, since they
> effectively (modulo the JRCXZ trick I posted a couple of days ago)
> cannot be used in loops, only in short unrolled code blocks.
>
> When you only need one chain of limited length, then plain old
> ADD/ADC/ADC/ADC... works perfectly well. Using only the new carry-based
> instruction makes it easier to create relatively normal loops since you
> can combine ADCX with LOOP.
> Terje
>
> --
> - <Terje.Mathisen at tmsw.no>
> "almost all programming can be viewed as an exercise in caching"

Re: Compact representation for common integer constants

<a464c1c6-40b0-4973-9c7e-cd4c4910db75n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17260&group=comp.arch#17260

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ad4:4713:: with SMTP id k19mr9827809qvz.26.1622315777977;
Sat, 29 May 2021 12:16:17 -0700 (PDT)
X-Received: by 2002:a9d:19ed:: with SMTP id k100mr11434037otk.329.1622315777748;
Sat, 29 May 2021 12:16:17 -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.arch
Date: Sat, 29 May 2021 12:16:17 -0700 (PDT)
In-Reply-To: <2021May29.184428@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:ad49:ec73:d3b9:bf72;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:ad49:ec73:d3b9:bf72
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s89ahe$t4n$1@dont-email.me> <26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com>
<s8lqsr$aru$1@dont-email.me> <88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com>
<s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org>
<s8nd5j$bas$1@dont-email.me> <2021May27.113439@mips.complang.tuwien.ac.at>
<s8ojhh$4b1$2@newsreader4.netcologne.de> <2021May28.165948@mips.complang.tuwien.ac.at>
<s8r75a$jj8$1@newsreader4.netcologne.de> <2021May29.184428@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a464c1c6-40b0-4973-9c7e-cd4c4910db75n@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 29 May 2021 19:16:17 +0000
Content-Type: text/plain; charset="UTF-8"
 by: MitchAlsup - Sat, 29 May 2021 19:16 UTC

On Saturday, May 29, 2021 at 11:48:56 AM UTC-5, Anton Ertl wrote:
> Thomas Koenig <tko...@netcologne.de> writes:
> >The ABI especially for C++
> >was taken from the Itanium ABI, which you can find at
> >https://itanium-cxx-abi.github.io/cxx-abi/ , so people refer to the
> >whole thing as the "Itanium ABI" although that is not 100% correct.
> Thanks. I am not into C++, so I have never heard about "Itanium ABI"
> before. A quick skim did not reveal anything about struct returns.
> It looks to me like this C++ ABI is based on the regular ABI (C and
> Fortran features), and defines various C++ things in terms of that,
> and that's why it can transcend individual architectures.
<
There is a large section that deals with the integration of TRY-THROW-CATCH
exception handling with longjump all integrated together. This whole mess
is stitched together with a personality module that knows how to access
ELF given an IP and annotate where on the stack the return IP is currently
stored. Along with this is some means of finding the "new" data and their
respective destructors. So the stack can be walked back remotely.
<
That section is as big as the C+FORTRAN ABI is big.
<
Which leads me to ask:: Has anyone structured the epilogues of C++
routines such that the calls to the destructors is an actual call in the
epilogue, so that one does not have to make walking the stack backwards
an interpreted affair, but the stack walker can simply call the same set
of destructors--vastly simplifying the problem space?? Ivan ??
<
> - anton
> --
> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>

Re: Compact representation for common integer constants

<s8u7t1$qdo$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17261&group=comp.arch#17261

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Sat, 29 May 2021 13:24:02 -0700
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <s8u7t1$qdo$1@dont-email.me>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s89ahe$t4n$1@dont-email.me>
<26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com>
<s8lqsr$aru$1@dont-email.me>
<88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com>
<s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org>
<s8nd5j$bas$1@dont-email.me> <2021May27.113439@mips.complang.tuwien.ac.at>
<s8ojhh$4b1$2@newsreader4.netcologne.de>
<2021May28.165948@mips.complang.tuwien.ac.at>
<s8r75a$jj8$1@newsreader4.netcologne.de>
<2021May29.184428@mips.complang.tuwien.ac.at>
<a464c1c6-40b0-4973-9c7e-cd4c4910db75n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 May 2021 20:24:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d736f09a1e8f8024993a3f546557f659";
logging-data="27064"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+plENtuhQRSBfNhtO18YvO"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Cancel-Lock: sha1:FMTvbfbzdz80qr1pjPL7UAxeXyA=
In-Reply-To: <a464c1c6-40b0-4973-9c7e-cd4c4910db75n@googlegroups.com>
Content-Language: en-US
 by: Ivan Godard - Sat, 29 May 2021 20:24 UTC

On 5/29/2021 12:16 PM, MitchAlsup wrote:
> On Saturday, May 29, 2021 at 11:48:56 AM UTC-5, Anton Ertl wrote:
>> Thomas Koenig <tko...@netcologne.de> writes:
>>> The ABI especially for C++
>>> was taken from the Itanium ABI, which you can find at
>>> https://itanium-cxx-abi.github.io/cxx-abi/ , so people refer to the
>>> whole thing as the "Itanium ABI" although that is not 100% correct.
>> Thanks. I am not into C++, so I have never heard about "Itanium ABI"
>> before. A quick skim did not reveal anything about struct returns.
>> It looks to me like this C++ ABI is based on the regular ABI (C and
>> Fortran features), and defines various C++ things in terms of that,
>> and that's why it can transcend individual architectures.
> <
> There is a large section that deals with the integration of TRY-THROW-CATCH
> exception handling with longjump all integrated together. This whole mess
> is stitched together with a personality module that knows how to access
> ELF given an IP and annotate where on the stack the return IP is currently
> stored. Along with this is some means of finding the "new" data and their
> respective destructors. So the stack can be walked back remotely.
> <
> That section is as big as the C+FORTRAN ABI is big.
> <
> Which leads me to ask:: Has anyone structured the epilogues of C++
> routines such that the calls to the destructors is an actual call in the
> epilogue, so that one does not have to make walking the stack backwards
> an interpreted affair, but the stack walker can simply call the same set
> of destructors--vastly simplifying the problem space?? Ivan ??

Funny you should mention my name. Mill kernel is in C++ (or will be - in
process), so throw/catch can't use interp. NYF

Re: Compact representation for common integer constants

<ca3e8474-4c8f-485b-a463-e3a62a6ad67cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17262&group=comp.arch#17262

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:a851:: with SMTP id r78mr10083323qke.95.1622320443106; Sat, 29 May 2021 13:34:03 -0700 (PDT)
X-Received: by 2002:a05:6808:117:: with SMTP id b23mr9877214oie.7.1622320442909; Sat, 29 May 2021 13:34:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!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.arch
Date: Sat, 29 May 2021 13:34:02 -0700 (PDT)
In-Reply-To: <a464c1c6-40b0-4973-9c7e-cd4c4910db75n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:ad49:ec73:d3b9:bf72; posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:ad49:ec73:d3b9:bf72
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com> <s89ahe$t4n$1@dont-email.me> <26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com> <s8lqsr$aru$1@dont-email.me> <88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com> <s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org> <s8nd5j$bas$1@dont-email.me> <2021May27.113439@mips.complang.tuwien.ac.at> <s8ojhh$4b1$2@newsreader4.netcologne.de> <2021May28.165948@mips.complang.tuwien.ac.at> <s8r75a$jj8$1@newsreader4.netcologne.de> <2021May29.184428@mips.complang.tuwien.ac.at> <a464c1c6-40b0-4973-9c7e-cd4c4910db75n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ca3e8474-4c8f-485b-a463-e3a62a6ad67cn@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 29 May 2021 20:34:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 55
 by: MitchAlsup - Sat, 29 May 2021 20:34 UTC

On Saturday, May 29, 2021 at 2:16:19 PM UTC-5, MitchAlsup wrote:
> On Saturday, May 29, 2021 at 11:48:56 AM UTC-5, Anton Ertl wrote:
> > Thomas Koenig <tko...@netcologne.de> writes:
> > >The ABI especially for C++
> > >was taken from the Itanium ABI, which you can find at
> > >https://itanium-cxx-abi.github.io/cxx-abi/ , so people refer to the
> > >whole thing as the "Itanium ABI" although that is not 100% correct.
> > Thanks. I am not into C++, so I have never heard about "Itanium ABI"
> > before. A quick skim did not reveal anything about struct returns.
> > It looks to me like this C++ ABI is based on the regular ABI (C and
> > Fortran features), and defines various C++ things in terms of that,
> > and that's why it can transcend individual architectures.
> <
> There is a large section that deals with the integration of TRY-THROW-CATCH
> exception handling with longjump all integrated together. This whole mess
> is stitched together with a personality module that knows how to access
> ELF given an IP and annotate where on the stack the return IP is currently
> stored. Along with this is some means of finding the "new" data and their
> respective destructors. So the stack can be walked back remotely.
> <
> That section is as big as the C+FORTRAN ABI is big.
> <
> Which leads me to ask:: Has anyone structured the epilogues of C++
> routines such that the calls to the destructors is an actual call in the
> epilogue, so that one does not have to make walking the stack backwards
> an interpreted affair, but the stack walker can simply call the same set
> of destructors--vastly simplifying the problem space?? Ivan ??
<
Perhaps my wording was insufficient::
<
I have been led to believe that the epilogue of a C++ routine needing
destructors is something like::
<
exit:
for( type = 0; type < types; type ++ )
for(i = 0; i < number; i++)
destructor[type]( pointer[i] );
LDM Rpreserved,[SP,offset]
add SP,SP,sizeof_stack_frame
return
<
Whereas if the epilogue was structured::
exit:
call subroutine_destructors( pointer_to_compiler_data_on_stack );
LDM Rpreserved,[SP,offset]
add SP,SP,sizeof_stack_frame
return
<
then the stack back walker could simple call "subroutine_destructors()" rather
than perform the double for loop in an interpreter.
<
> <
> > - anton
> > --
> > 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> > Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>

Re: Compact representation for common integer constants

<jwv35u50yao.fsf-monnier+comp.arch@gnu.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17267&group=comp.arch#17267

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monn...@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Sat, 29 May 2021 22:18:53 -0400
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <jwv35u50yao.fsf-monnier+comp.arch@gnu.org>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s89ahe$t4n$1@dont-email.me>
<26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com>
<s8lqsr$aru$1@dont-email.me>
<88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com>
<s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org>
<s8nd5j$bas$1@dont-email.me>
<2021May27.113439@mips.complang.tuwien.ac.at>
<s8ojhh$4b1$2@newsreader4.netcologne.de>
<2021May28.165948@mips.complang.tuwien.ac.at>
<s8r75a$jj8$1@newsreader4.netcologne.de>
<2021May29.184428@mips.complang.tuwien.ac.at>
<a464c1c6-40b0-4973-9c7e-cd4c4910db75n@googlegroups.com>
<ca3e8474-4c8f-485b-a463-e3a62a6ad67cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="8d76a67f1a3383bf515805af7b8f4a24";
logging-data="567"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZaiQip8Qs1sMoVrQca6Ii"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Cancel-Lock: sha1:CNmwNrZa3UUCpkpw02eRym4CXAs=
sha1:gjYCBPcrVGlU6FGXgAmLipIxW8A=
 by: Stefan Monnier - Sun, 30 May 2021 02:18 UTC

> Perhaps my wording was insufficient::
> <
> I have been led to believe that the epilogue of a C++ routine needing
> destructors is something like::
> <
> exit:
> for( type = 0; type < types; type ++ )
> for(i = 0; i < number; i++)
> destructor[type]( pointer[i] );
> LDM Rpreserved,[SP,offset]
> add SP,SP,sizeof_stack_frame
> return
> <
> Whereas if the epilogue was structured::
> exit:
> call subroutine_destructors( pointer_to_compiler_data_on_stack );
> LDM Rpreserved,[SP,offset]
> add SP,SP,sizeof_stack_frame
> return
> <
> then the stack back walker could simple call "subroutine_destructors()" rather
> than perform the double for loop in an interpreter.

I suspect this design choice was made under the hypothesis that
non-local exits are rare: this design allows the "normal exit" case to
be implemented more efficiently (basically by inlining your
`subroutine_destructors` function) at the cost of a slower stack-walk.

Also, maybe the "slow interpreted stack walk" is not quite as slow as it
looks because its code is a small loop that might more easily fit into
the I$ than your `subroutine_destructors` functions which would end up
scattered all over the code segment and occupying more space?

I'm really asking the question: I don't know the answer at all.
It just reminded me of a similar situation for GCs where it's usually
more efficient to have each object come with a pointer to a small
data-structure describing which fields hold data in which format (and
then have a small loop "interpret" that data-structure to find the
pointers) than to have each object come with a pointer to a chunk of
code that "marks" or "copies" objects of that type.
Of course, the tradeoff depends on the complexity of the data-structure
that needs to be interpreted, but usually (for GCs) you can arrange for
it to be sufficiently simple that it ends up being a very
efficient/tight loop.

Stefan

Re: Compact representation for common integer constants

<s8vgj6$ec1$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17269&group=comp.arch#17269

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-e5ed-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Sun, 30 May 2021 07:58:30 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s8vgj6$ec1$1@newsreader4.netcologne.de>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s89ahe$t4n$1@dont-email.me>
<26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com>
<s8lqsr$aru$1@dont-email.me>
<88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com>
<s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org>
<s8nd5j$bas$1@dont-email.me> <2021May27.113439@mips.complang.tuwien.ac.at>
<s8ojhh$4b1$2@newsreader4.netcologne.de>
<2021May28.165948@mips.complang.tuwien.ac.at>
<s8r75a$jj8$1@newsreader4.netcologne.de>
<2021May29.184428@mips.complang.tuwien.ac.at>
Injection-Date: Sun, 30 May 2021 07:58:30 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-e5ed-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:e5ed:0:7285:c2ff:fe6c:992d";
logging-data="14721"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 30 May 2021 07:58 UTC

Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
> Thomas Koenig <tkoenig@netcologne.de> writes:
>>The ABI especially for C++
>>was taken from the Itanium ABI, which you can find at
>>https://itanium-cxx-abi.github.io/cxx-abi/ , so people refer to the
>>whole thing as the "Itanium ABI" although that is not 100% correct.
>
> Thanks. I am not into C++, so I have never heard about "Itanium ABI"
> before. A quick skim did not reveal anything about struct returns.

For that, you want to look for the different "Architecture Processor
Supplement"s to the "System V Application Binary Interface".

Offhand, I can find it for AMD64 and for MIPS.

> It looks to me like this C++ ABI is based on the regular ABI (C and
> Fortran features), and defines various C++ things in terms of that,
> and that's why it can transcend individual architectures.

That is correct.

Re: arithmetic fast and slow, was FP8 (was Compact representation for common integer constants)

<2021Jun3.184903@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17352&group=comp.arch#17352

  copy link   Newsgroups: comp.arch
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.arch
Subject: Re: arithmetic fast and slow, was FP8 (was Compact representation for common integer constants)
Date: Thu, 03 Jun 2021 16:49:03 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 25
Message-ID: <2021Jun3.184903@mips.complang.tuwien.ac.at>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com> <2021May10.101544@mips.complang.tuwien.ac.at> <s7brr7$1da5$1@gal.iecc.com> <2021May12.190836@mips.complang.tuwien.ac.at> <s7hdel$sp1$2@gal.iecc.com>
Injection-Info: reader02.eternal-september.org; posting-host="c660a4d80459a6fcc440eafa0dd818d4";
logging-data="5079"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kGvdVYoejZBK0m4HP89wL"
Cancel-Lock: sha1:0i8UJP0f/+uiTgvqw/af+hEUg4c=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 3 Jun 2021 16:49 UTC

John Levine <johnl@taugh.com> writes:
>It does make the assertion that he rewrote everything in fixed point to
>make it faster seem a bit naive.

I have now found the data from Bentley's book:

PDP-KL10 HP1000 # step
Pascal C
5.73 4.39 1 Original
5.56 4.27 2 Common Subexpression Elimination
2.95 2.78 3 Eliminate sqrt()
2.59 2.63 4 Eliminate visited[]
1.71 1.72 5 Inline DistSqrd()
1 1 6 Compute Y-Distance later
0.91 0.86 7 Integers instead of Floats
0.84 0.84 8 Direct reordering instead of using index array
0.83 - 9 Sentinel

Step 7 is the one relevant to this discussion. So he saw a speedup,
but it was not very big.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: Compact representation for common integer constants

<c46b14cb-c261-468c-9b65-0480bc54431cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17407&group=comp.arch#17407

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:988:: with SMTP id x8mr5557950qkx.6.1622843484829;
Fri, 04 Jun 2021 14:51:24 -0700 (PDT)
X-Received: by 2002:a9d:2287:: with SMTP id y7mr5190475ota.22.1622843484646;
Fri, 04 Jun 2021 14:51:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.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.arch
Date: Fri, 4 Jun 2021 14:51:24 -0700 (PDT)
In-Reply-To: <s7bo65$9gq$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:56a:f8e3:d700:eca4:8396:11d7:5173;
posting-account=1nOeKQkAAABD2jxp4Pzmx9Hx5g9miO8y
NNTP-Posting-Host: 2001:56a:f8e3:d700:eca4:8396:11d7:5173
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s6udkp$hs5$1@dont-email.me> <6a45a966-9d86-40ed-9b16-67766956d46fn@googlegroups.com>
<s74akj$siq$1@dont-email.me> <f94d31bd-ae99-4d0a-84d3-d16e9ba71c6fn@googlegroups.com>
<s74muh$vqf$1@dont-email.me> <s789v4$rv6$1@newsreader4.netcologne.de>
<s7a8u7$mui$1@dont-email.me> <9f36daff-8b8f-4550-80ad-2f75dd98f319n@googlegroups.com>
<s7bo65$9gq$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c46b14cb-c261-468c-9b65-0480bc54431cn@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: jsav...@ecn.ab.ca (Quadibloc)
Injection-Date: Fri, 04 Jun 2021 21:51:24 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Quadibloc - Fri, 4 Jun 2021 21:51 UTC

On Monday, May 10, 2021 at 10:49:11 AM UTC-6, Ivan Godard wrote:

> Do you have any saturating multiplies? Why or why not?

Not realizing that anyone would find them useful, I had not
included them even in my everything but the kitchen sink
original Concertina architecture.

But if they are useful, although in _some_ places opcode
space is at a premium, I have plenty of space for additional
operate instructions.

John Savard

Re: Compact representation for common integer constants

<24b396e7-25b2-456b-967b-cbb98f68a9b4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17415&group=comp.arch#17415

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:4d0:: with SMTP id 16mr6658674qks.496.1622848704018;
Fri, 04 Jun 2021 16:18:24 -0700 (PDT)
X-Received: by 2002:a05:6808:1496:: with SMTP id e22mr4781018oiw.78.1622848703798;
Fri, 04 Jun 2021 16:18:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.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.arch
Date: Fri, 4 Jun 2021 16:18:23 -0700 (PDT)
In-Reply-To: <c46b14cb-c261-468c-9b65-0480bc54431cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:d86e:2dae:1be0:6121;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:d86e:2dae:1be0:6121
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s6udkp$hs5$1@dont-email.me> <6a45a966-9d86-40ed-9b16-67766956d46fn@googlegroups.com>
<s74akj$siq$1@dont-email.me> <f94d31bd-ae99-4d0a-84d3-d16e9ba71c6fn@googlegroups.com>
<s74muh$vqf$1@dont-email.me> <s789v4$rv6$1@newsreader4.netcologne.de>
<s7a8u7$mui$1@dont-email.me> <9f36daff-8b8f-4550-80ad-2f75dd98f319n@googlegroups.com>
<s7bo65$9gq$1@dont-email.me> <c46b14cb-c261-468c-9b65-0480bc54431cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <24b396e7-25b2-456b-967b-cbb98f68a9b4n@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Fri, 04 Jun 2021 23:18:24 +0000
Content-Type: text/plain; charset="UTF-8"
 by: MitchAlsup - Fri, 4 Jun 2021 23:18 UTC

On Friday, June 4, 2021 at 4:51:26 PM UTC-5, Quadibloc wrote:
> On Monday, May 10, 2021 at 10:49:11 AM UTC-6, Ivan Godard wrote:
>
> > Do you have any saturating multiplies? Why or why not?
>
> Not realizing that anyone would find them useful, I had not
> included them even in my everything but the kitchen sink
> original Concertina architecture.
>
> But if they are useful, although in _some_ places opcode
> space is at a premium, I have plenty of space for additional
> operate instructions.
<
You could borrow the My 66000 trick and use a SAT instruction to
add saturation to several of the following instructions, avoiding the
OpCode space premium.
>
> John Savard

Re: Compact representation for common integer constants

<88ca4ffe-3a3c-43cb-9c4a-f6d3d77d1a3an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17476&group=comp.arch#17476

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5d88:: with SMTP id d8mr13021953qtx.147.1622995217915;
Sun, 06 Jun 2021 09:00:17 -0700 (PDT)
X-Received: by 2002:a9d:1d49:: with SMTP id m67mr11235683otm.76.1622995217660;
Sun, 06 Jun 2021 09:00:17 -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.arch
Date: Sun, 6 Jun 2021 09:00:17 -0700 (PDT)
In-Reply-To: <24b396e7-25b2-456b-967b-cbb98f68a9b4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:56a:f8e3:d700:dd8f:87d8:eab2:518c;
posting-account=1nOeKQkAAABD2jxp4Pzmx9Hx5g9miO8y
NNTP-Posting-Host: 2001:56a:f8e3:d700:dd8f:87d8:eab2:518c
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s6udkp$hs5$1@dont-email.me> <6a45a966-9d86-40ed-9b16-67766956d46fn@googlegroups.com>
<s74akj$siq$1@dont-email.me> <f94d31bd-ae99-4d0a-84d3-d16e9ba71c6fn@googlegroups.com>
<s74muh$vqf$1@dont-email.me> <s789v4$rv6$1@newsreader4.netcologne.de>
<s7a8u7$mui$1@dont-email.me> <9f36daff-8b8f-4550-80ad-2f75dd98f319n@googlegroups.com>
<s7bo65$9gq$1@dont-email.me> <c46b14cb-c261-468c-9b65-0480bc54431cn@googlegroups.com>
<24b396e7-25b2-456b-967b-cbb98f68a9b4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <88ca4ffe-3a3c-43cb-9c4a-f6d3d77d1a3an@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: jsav...@ecn.ab.ca (Quadibloc)
Injection-Date: Sun, 06 Jun 2021 16:00:17 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Quadibloc - Sun, 6 Jun 2021 16:00 UTC

On Friday, June 4, 2021 at 5:18:25 PM UTC-6, MitchAlsup wrote:

> You could borrow the My 66000 trick and use a SAT instruction to
> add saturation to several of the following instructions, avoiding the
> OpCode space premium.

At the moment, I don't inclulde any kind of prefixed instruction, since
that would mean that it would no longer be the case that, once the block
header is decoded, the computer now knows where every instruction in
the block starts, and can just decode it and (except for stuff like
dependencies) run with it.

This is why I've gone to such lengths to have determination of instruction
length require _zero_ gate delays per individual instruction. There are a
few gate delays for the block as a whole, then that's it, no matter how many
instructions there are in the block.

However, I have a header format allowing accelerated emulation of instruction
sets where instruction lengths are multiples of 16 bits. Like the 360 or the 680x0.
So this architecture is capable of just *borrowing the entire My 66000 ISA*.

I may end up, once I figure out a worthwhile way of translating addresses, adding
a bit to that header format to enable or disable address conversion - addresses in
jump instructions, at the moment, have to be changed to actual addresses in memory
allowing for each block having 32 overhead bits. True emulation would allow running
programs in the target ISA intact, without modification, but I want to avoid having to
indicate a starting point for the multiplication by 8/7.

John Savard

Re: Compact representation for common integer constants

<868s38csh9.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17869&group=comp.arch#17869

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Thu, 17 Jun 2021 10:26:42 -0700
Organization: A noiseless patient Spider
Lines: 201
Message-ID: <868s38csh9.fsf@linuxsc.com>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com> <s7v6j1$qns$1@dont-email.me> <s7vn9p$bfu$1@newsreader4.netcologne.de> <2021May18.183723@mips.complang.tuwien.ac.at> <s80rjn$1ci$2@newsreader4.netcologne.de> <2021May19.124934@mips.complang.tuwien.ac.at> <d5edb86e-0166-4c44-83eb-19e1cd8eb2c4n@googlegroups.com> <nqapI.385883$2A5.264183@fx45.iad> <s84b5i$mal$1@dont-email.me> <igmeioFr49pU1@mid.individual.net> <s85u1e$2nb$1@dont-email.me> <51fddd24-666f-4914-9161-30e010e0ef92n@googlegroups.com> <s864if$mqg$1@dont-email.me> <q1UpI.60399$DZ5.42895@fx23.iad> <s89ahe$t4n$1@dont-email.me> <26c0c173-a5b3-4852-8bb9-914ad7252f05n@googlegroups.com> <s8lqsr$aru$1@dont-email.me> <88b2b9c9-2b2f-4c61-abe7-d11dbfbe6fe2n@googlegroups.com> <s8m1ke$u2m$1@dont-email.me> <s8nc3e$pi7$1@gioia.aioe.org> <s8nd5j$bas$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="f0b9b4b9a1b21005dc3e7b402c48f6f1";
logging-data="25994"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/C0sTdrxhSsvZfOlPFXxXJ9tkY3NOEjH8="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:qCmYqSPe4e6X7OApT56wdo/pe1c=
sha1:wH2zkwKFOIkj6+OmE6Jkrnf5pBk=
 by: Tim Rentsch - Thu, 17 Jun 2021 17:26 UTC

Ivan Godard <ivan@millcomputing.com> writes:

> On 5/26/2021 10:52 PM, Terje Mathisen wrote:
>
>> Ivan Godard wrote:
>>
>>> On 5/26/2021 10:04 AM, MitchAlsup wrote:
>>>
>>>> On Wednesday, May 26, 2021 at 10:53:02 AM UTC-5, Stephen Fuld wrote:
>>>>
>>>>> On 5/21/2021 3:59 PM, MitchAlsup wrote:
>>>>>
>>>>>> On Friday, May 21, 2021 at 5:00:17 PM UTC-5, Stephen Fuld wrote:
>>>>>>
>>>>>>> On 5/21/2021 12:40 PM, EricP wrote:
>>>>>>>
>>>>>>>> Stephen Fuld wrote:
>>>>>>>>
>>>>>>>>> On 5/20/2021 9:34 AM, MitchAlsup wrote:
>>>>>>>>>
>>>>>>>>>> On Thursday, May 20, 2021 at 10:08:32 AM UTC-5, Stephen Fuld
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> On 5/19/2021 11:40 PM, Niklas Holsti wrote:
>>>>>>>>>>>
>>>>>>>>>>>> On 2021-05-20 3:40, Stephen Fuld wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> On 5/19/2021 8:47 AM, EricP wrote:
>>>>>>>>>>>
>>>>>>>>>>> Fair enough. This sort of gets back to the question of
>>>>>>>>>>> whether to add a
>>>>>>>>>>> feature like this as an attribute of the variable
>>>>>>>>>>> (e.g. range) or of
>>>>>>>>>>> the
>>>>>>>>>>> operation (e.g. bignum). I think there are arguments for each.
>>>>>>>>>>>
>>>>>>>>>>> BTW, I am unsure of what the requirement is here. Suppose
>>>>>>>>>>> you have a
>>>>>>>>>>> variable with a range of 10-90. Do you want saturation at
>>>>>>>>>>> 90? That is
>>>>>>>>>>
>>>>>>>>>> If the value to be written is outside of the range [10..90]
>>>>>>>>>> you raise an
>>>>>>>>>> exception. The raised exception decides what to do.
>>>>>>>>>
>>>>>>>>> Certainly true for the non-saturating case, and is what Ada
>>>>>>>>> does. My
>>>>>>>>> question is if you define saturating variables, what to do if you
>>>>>>>>> somehow define the variable with a range *and* saturating.
>>>>>>>>
>>>>>>>> Any variables that are smaller than the machine register size are
>>>>>>>> promoted to that size by either sign or zero extension.
>>>>>>>>
>>>>>>>> Expressions are executed using signed or unsigned checked or
>>>>>>>> saturating
>>>>>>>> operations at that machine size. This detects intermediate signed or
>>>>>>>> unsigned overflows of the machine size results.
>>>>>>>>
>>>>>>>> I have instructions for trap on unsigned carry or signed overflow.
>>>>>>>> I have an ADGO Add Generate Overflow and ADGC Add Generate Carry
>>>>>>>> to set a 1 in the output register for overflow or carry.
>>>>>>>> Then a LIC Load Immediate Conditional loads saturation limit values.
>>>>>>>> One could have arithmetic instructions that saturate.
>>>>>>>>
>>>>>>>> The result is copied back to the variable. If there are
>>>>>>>> constraints on
>>>>>>>> the variable different from the limits on the physical register
>>>>>>>> then those are range checked and either saturated or trapped.
>>>>>>>> A CMPGT and CMPLT with a LIC loads upper or lower saturation value.
>>>>>>>>
>>>>>>>> Note that setting limits on variable to be in the range 10..90 does
>>>>>>>> not mean that expression intermediate results are within that range.
>>>>>>>> It means an expression EITHER produces the arithmetically
>>>>>>>> correct result
>>>>>>>> in that range, or it saturates or traps.
>>>>>>>
>>>>>>> That is certainly one way to do it. All the different ways have
>>>>>>> drawbacks. Mitch pointed out some of the ones for you choice in his
>>>>>>> followup.
>>>>>>>
>>>>>>> I don't know enough to have strong feelings as to the best choice. As
>>>>>>> Thomas Koening said earlier in this thread, it takes a lot of
>>>>>>> thought.
>>>>>>
>>>>>> This brings to mind that the whole concept of arithmetic exceptions is
>>>>>> fundamentally flawed.
>>>>>> It is not the arithmetic that should be checked for out-of-range
>>>>>> values
>>>>>> it is the depositing of values into containers that should be checked.
>>>>>
>>>>> While I generally agree, there is apparently some use for checking
>>>>> intermediate results in calculations. Then the question becomes what is
>>>>> the best way, language syntax wise (i.e. not a question of ISA,
>>>>> as there
>>>>> are several ways to do that depending upon ISA) to indicate that.
>>>>>
>>>>> Note that I am going to consider this in terms a generalized range
>>>>> restriction a` la Ada Range attributes, as resolving this for that case
>>>>> automatically includes the cases of overflow of byte sized variables in
>>>>> 64 bit registers, etc.
>>>>>
>>>>> Perhaps the easiest way to indicate this is the break the calculation
>>>>> into individual steps, storing the intermediate results, thus
>>>>> triggering
>>>>> the range checks.
>>>>>
>>>>> Lets use a simple example.
>>>>>
>>>>> X = A + B - C where A+B might be out of range, but after C is
>>>>> subtracted
>>>>> X is within range.
>>>>>
>>>>> You could code this as
>>>>>
>>>>> X = A + B
>>>>> X = X - C
>>>>
>>>> In general, I am a great fan of shorter assignment statements (as above)
>>>> and while there are more assignments, there may be fewer instructions
>>>> created, and the programmer himself can see the common sub-expressions.
>>>>
>>>>> Of course, the compiler would have to recognize that X had a range and
>>>>> actually do the check, even if it doesn't actually do the first store.
>>>>>
>>>>> Another alternative is the use a "function" to indicate that the check
>>>>> should be done. This is a generalization of the cast mechanism in C.
>>>>>
>>>>> i.e. something like
>>>>>
>>>>> X = Rangechk (A + B) - C ; Rangechk tests the bounds of X
>>>>>
>>>>>
>>>>> Another alternative is back to the discussion of whether the
>>>>> checking of
>>>>> intermediate values should be a property of the variable (like Range
>>>>> itself) or the calculation. If it is a property of the variable you
>>>>> could have syntax to indicate that, i.e. add RangeIVC (for intermediate
>>>>> value checked), which would indicate to check the intermediate values
>>>>> for any expression that assigns a value to the variable with that
>>>>> attribute.
>>>>>
>>>>> I don't have a strong feeling about what is the best solution,
>>>>> and there
>>>>> may be better ones than what I have suggested.
>>>>
>>>> May I suggest a whip instead of a language addition !! That is the code
>>>> review process should not allow x = a + b - c; into production code if
>>>> there is any reason to believe it can behave maliciously !! or unbox
>>>> the nasal demons of destruction !
>>>> There are codes which depend on the HW not caring that something
>>>> has lost precision on one end (integral) or the other (FP). For example
>>>> Knuth's TwoSum::
>>>> {double, double} TwoSum( double a, double b )
>>>> { // Knuth
>>>> x = a + b ;
>>>> q = x - a ;
>>>> r = x - q ;
>>>> s = b - q ;
>>>> t = a - r ;
>>>> y = s + t ;
>>>> return { x, y };
>>>> }
>>>> This subroutine performs addition and puts all of the bits of a+b that
>>>> fit into x, and all of the bits that do not fit into y,
>>>> branchlessly. The
>>>> numerical analyst went to great trouble to align all the arithmetic
>>>> so that precisely this would be the result.
>>>> An "optimizing" might come to the conclusion that q == b and ruin
>>>> the whole sequence !!
>>>> On the other hand I designed My 66000 so that one can write this as::
>>>> {double, double} TwoSum( double a, double b )
>>>> {
>>>> return {double, double} = a + b;
>>>> }
>>>
>>> Does your actual compiler currently accept this as source? If not,
>>> what do you actually have to write to get the requisite machine
>>> code from your implemented compiler?
>>
>> The traditional C way, as exemplified by lots of compiler
>> intrinsics, is to use a pointer to any additional return values:
>>
>> double AugmentedAddition(double a, double b, double *lopart)
>> {
>> // Knuth
>> x = a + b ;
>> q = x - a ;
>> r = x - q ;
>> s = b - q ;
>> t = a - r ;
>> *lopart = s + t ;
>> return x;
>> }
>>
>> I.e. Intel's add_carryx_u64() returns both the full adder result and
>> the outgoing carry.
>
> Which is regrettable when without restrict and inlining, and doubtful
> even then.


Click here to read the complete article
Re: Compact representation for common integer constants

<86zgvobdd4.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17873&group=comp.arch#17873

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Thu, 17 Jun 2021 10:38:31 -0700
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <86zgvobdd4.fsf@linuxsc.com>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com> <bcd3dd9a-cfcd-4691-9163-842ddf1f483dn@googlegroups.com> <s7u338$cek$1@newsreader4.netcologne.de> <s7v6j1$qns$1@dont-email.me> <s7vn9p$bfu$1@newsreader4.netcologne.de> <2021May18.183723@mips.complang.tuwien.ac.at> <s80rjn$1ci$2@newsreader4.netcologne.de> <2021May19.124934@mips.complang.tuwien.ac.at> <s83h0k$jaj$1@newsreader4.netcologne.de> <2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me> <2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me> <35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com> <s84b0a$lht$1@dont-email.me> <5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com> <s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me> <s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me> <s86des$g1a$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="f0b9b4b9a1b21005dc3e7b402c48f6f1";
logging-data="25994"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/poIX+gGoirocqibDr7Ef2EBux0o696zw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:S3EY/VXHxyCcHcIlzVKdLUpUA00=
sha1:qzqlOcgO4Tbh6TWe1xUVYjdTjoA=
 by: Tim Rentsch - Thu, 17 Jun 2021 17:38 UTC

Thomas Koenig <tkoenig@netcologne.de> writes:

> Marcus <m.delete@this.bitsnbites.eu> schrieb:
>
>> A common source of
>> errors is implicit type conversions in C, for instance.
>
> The integral promotions from signed to unsigned of the
> same size are the worst.
>
> int a = -3;
> unsigned int b = 2;
> if (a > b)
> printf ("You expected this to happen, right?\n");

The C standard uses the term "integer promotions" rather than
"integral promotions", but in any case what is going on here
falls under the heading of "usual arithmetic conversions",
not "integer promotions". (Integer promotions are things
like turning a 'short' into an 'int'.)

Re: Compact representation for common integer constants

<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17877&group=comp.arch#17877

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:660d:: with SMTP id c13mr4628049qtp.193.1623954166032; Thu, 17 Jun 2021 11:22:46 -0700 (PDT)
X-Received: by 2002:a05:6830:33ea:: with SMTP id i10mr5623326otu.342.1623954165817; Thu, 17 Jun 2021 11:22:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!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.arch
Date: Thu, 17 Jun 2021 11:22:45 -0700 (PDT)
In-Reply-To: <86zgvobdd4.fsf@linuxsc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:3d96:df7c:31b3:6d42; posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:3d96:df7c:31b3:6d42
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com> <bcd3dd9a-cfcd-4691-9163-842ddf1f483dn@googlegroups.com> <s7u338$cek$1@newsreader4.netcologne.de> <s7v6j1$qns$1@dont-email.me> <s7vn9p$bfu$1@newsreader4.netcologne.de> <2021May18.183723@mips.complang.tuwien.ac.at> <s80rjn$1ci$2@newsreader4.netcologne.de> <2021May19.124934@mips.complang.tuwien.ac.at> <s83h0k$jaj$1@newsreader4.netcologne.de> <2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me> <2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me> <35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com> <s84b0a$lht$1@dont-email.me> <5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com> <s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me> <s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me> <s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 17 Jun 2021 18:22:46 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 30
 by: MitchAlsup - Thu, 17 Jun 2021 18:22 UTC

On Thursday, June 17, 2021 at 12:38:33 PM UTC-5, Tim Rentsch wrote:
> Thomas Koenig <tko...@netcologne.de> writes:
>
> > Marcus <m.de...@this.bitsnbites.eu> schrieb:
> >
> >> A common source of
> >> errors is implicit type conversions in C, for instance.
> >
> > The integral promotions from signed to unsigned of the
> > same size are the worst.
> >
> > int a = -3;
> > unsigned int b = 2;
> > if (a > b)
> > printf ("You expected this to happen, right?\n");
>
> The C standard uses the term "integer promotions" rather than
> "integral promotions", but in any case what is going on here
> falls under the heading of "usual arithmetic conversions",
> not "integer promotions". (Integer promotions are things
> like turning a 'short' into an 'int'.)
<
What causes the supersize is that programmers are not taught
unsigned has a lower surprise factor than integer.
<
But consider::
<
int64_t a = -3;
uint64_t b = 0xfffffffffffffffd;
if( a == b )
printf ("You expected this to happen, right?\n");

Re: Compact representation for common integer constants

<sag7gi$9ur$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17882&group=comp.arch#17882

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Thu, 17 Jun 2021 21:24:02 +0200
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <sag7gi$9ur$1@dont-email.me>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<bcd3dd9a-cfcd-4691-9163-842ddf1f483dn@googlegroups.com>
<s7u338$cek$1@newsreader4.netcologne.de> <s7v6j1$qns$1@dont-email.me>
<s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at>
<s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at>
<s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com>
<s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com>
<s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me>
<s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Jun 2021 19:24:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="47806edb1ac76cf0c43f58ddf1f0661c";
logging-data="10203"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zCnTGqhE87Pe5cQQvgyeO5TX8EXtVZEc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:0qzaIL/gE/5VxZP3oHZ09xXsGNU=
In-Reply-To: <4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Thu, 17 Jun 2021 19:24 UTC

On 17/06/2021 20:22, MitchAlsup wrote:
> On Thursday, June 17, 2021 at 12:38:33 PM UTC-5, Tim Rentsch wrote:
>> Thomas Koenig <tko...@netcologne.de> writes:
>>
>>> Marcus <m.de...@this.bitsnbites.eu> schrieb:
>>>
>>>> A common source of
>>>> errors is implicit type conversions in C, for instance.
>>>
>>> The integral promotions from signed to unsigned of the
>>> same size are the worst.
>>>
>>> int a = -3;
>>> unsigned int b = 2;
>>> if (a > b)
>>> printf ("You expected this to happen, right?\n");
>>
>> The C standard uses the term "integer promotions" rather than
>> "integral promotions", but in any case what is going on here
>> falls under the heading of "usual arithmetic conversions",
>> not "integer promotions". (Integer promotions are things
>> like turning a 'short' into an 'int'.)
> <
> What causes the supersize is that programmers are not taught
> unsigned has a lower surprise factor than integer.

unsigned types in C don't have "lower surprise factor" than signed
types. They have slightly /different/ surprise factors. If you want to
program in C, you should learn how the signed and unsigned integer types
work, alone and together, and code accordingly.

There is a lot of value in using good static warning tools - enabling
"-Wsign-compare -Wsign-conversion" in gcc will give you warnings on
these things if you don't use explicit casts. You choose your own
balance between reduced risk of errors at the cost of additional effort
(such as casts) when you need to mixed signedness and know it is safe.

One problem with a lot of C teaching is that it usually fails to teach
about tools that can make programming easier and safer. Another is that
if they teach the details of integer types at all, they do so with
invalid and unhelpful generalisations like "unsigned types are better
because overflow is defined and they are therefore safe".

> <
> But consider::
> <
> int64_t a = -3;
> uint64_t b = 0xfffffffffffffffd;
> if( a == b )
> printf ("You expected this to happen, right?\n");
>

Re: Compact representation for common integer constants

<sag8p5$il8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17883&group=comp.arch#17883

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Thu, 17 Jun 2021 12:45:42 -0700
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <sag8p5$il8$1@dont-email.me>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<bcd3dd9a-cfcd-4691-9163-842ddf1f483dn@googlegroups.com>
<s7u338$cek$1@newsreader4.netcologne.de> <s7v6j1$qns$1@dont-email.me>
<s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at>
<s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at>
<s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com>
<s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com>
<s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me>
<s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
<sag7gi$9ur$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Jun 2021 19:45:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="67de17296d1dcb619583fd574974f8f7";
logging-data="19112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HSMwgX3SH30hmZoteybwm"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:+NK11/UQgDP8E4JKtiWlevTDsm0=
In-Reply-To: <sag7gi$9ur$1@dont-email.me>
Content-Language: en-US
 by: Ivan Godard - Thu, 17 Jun 2021 19:45 UTC

On 6/17/2021 12:24 PM, David Brown wrote:
> On 17/06/2021 20:22, MitchAlsup wrote:
>> On Thursday, June 17, 2021 at 12:38:33 PM UTC-5, Tim Rentsch wrote:
>>> Thomas Koenig <tko...@netcologne.de> writes:
>>>
>>>> Marcus <m.de...@this.bitsnbites.eu> schrieb:
>>>>
>>>>> A common source of
>>>>> errors is implicit type conversions in C, for instance.
>>>>
>>>> The integral promotions from signed to unsigned of the
>>>> same size are the worst.
>>>>
>>>> int a = -3;
>>>> unsigned int b = 2;
>>>> if (a > b)
>>>> printf ("You expected this to happen, right?\n");
>>>
>>> The C standard uses the term "integer promotions" rather than
>>> "integral promotions", but in any case what is going on here
>>> falls under the heading of "usual arithmetic conversions",
>>> not "integer promotions". (Integer promotions are things
>>> like turning a 'short' into an 'int'.)
>> <
>> What causes the supersize is that programmers are not taught
>> unsigned has a lower surprise factor than integer.
>
> unsigned types in C don't have "lower surprise factor" than signed
> types. They have slightly /different/ surprise factors. If you want to
> program in C, you should learn how the signed and unsigned integer types
> work, alone and together, and code accordingly.
>
> There is a lot of value in using good static warning tools - enabling
> "-Wsign-compare -Wsign-conversion" in gcc will give you warnings on
> these things if you don't use explicit casts. You choose your own
> balance between reduced risk of errors at the cost of additional effort
> (such as casts) when you need to mixed signedness and know it is safe.
>
> One problem with a lot of C teaching is that it usually fails to teach
> about tools that can make programming easier and safer. Another is that
> if they teach the details of integer types at all, they do so with
> invalid and unhelpful generalisations like "unsigned types are better
> because overflow is defined and they are therefore safe".
>
>> <
>> But consider::
>> <
>> int64_t a = -3;
>> uint64_t b = 0xfffffffffffffffd;
>> if( a == b )
>> printf ("You expected this to happen, right?\n");
>>
>

The warnings are necessary, but still annoying:
for (int i = 0; i < arr.size(); i++)

for example.

Re: Compact representation for common integer constants

<dde59e65-0dc9-489c-bb97-873248d2ff74n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17891&group=comp.arch#17891

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:a8a:: with SMTP id ev10mr2256180qvb.52.1623968675920;
Thu, 17 Jun 2021 15:24:35 -0700 (PDT)
X-Received: by 2002:a9d:7f8f:: with SMTP id t15mr6231555otp.329.1623968675715;
Thu, 17 Jun 2021 15:24:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.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.arch
Date: Thu, 17 Jun 2021 15:24:35 -0700 (PDT)
In-Reply-To: <sag8p5$il8$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:56a:f8e3:d700:9d3b:eb08:6be5:9836;
posting-account=1nOeKQkAAABD2jxp4Pzmx9Hx5g9miO8y
NNTP-Posting-Host: 2001:56a:f8e3:d700:9d3b:eb08:6be5:9836
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<bcd3dd9a-cfcd-4691-9163-842ddf1f483dn@googlegroups.com> <s7u338$cek$1@newsreader4.netcologne.de>
<s7v6j1$qns$1@dont-email.me> <s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at> <s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at> <s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com> <s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com> <s8522o$tol$1@dont-email.me>
<s85i3s$929$1@dont-email.me> <s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com> <sag7gi$9ur$1@dont-email.me>
<sag8p5$il8$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dde59e65-0dc9-489c-bb97-873248d2ff74n@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: jsav...@ecn.ab.ca (Quadibloc)
Injection-Date: Thu, 17 Jun 2021 22:24:35 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Quadibloc - Thu, 17 Jun 2021 22:24 UTC

On Thursday, June 17, 2021 at 1:45:44 PM UTC-6, Ivan Godard wrote:

> The warnings are necessary, but still annoying:
> for (int i = 0; i < arr.size(); i++)

> for example.

....because arr.size(), derived as it is from addresses, naturally
has unsigned type. But this is surprising to programmers coming
from languages that don't bother to provide the unsigned
integer type.

John Savard

Re: Compact representation for common integer constants

<6d654e64-9393-4b58-9954-2b83e88d78e4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17893&group=comp.arch#17893

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:2225:: with SMTP id n5mr6677900qkh.38.1623973580354;
Thu, 17 Jun 2021 16:46:20 -0700 (PDT)
X-Received: by 2002:a05:6830:1643:: with SMTP id h3mr6914581otr.76.1623973580145;
Thu, 17 Jun 2021 16:46:20 -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.arch
Date: Thu, 17 Jun 2021 16:46:19 -0700 (PDT)
In-Reply-To: <sag7gi$9ur$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:89a3:951e:b53:5b9b;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:89a3:951e:b53:5b9b
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<bcd3dd9a-cfcd-4691-9163-842ddf1f483dn@googlegroups.com> <s7u338$cek$1@newsreader4.netcologne.de>
<s7v6j1$qns$1@dont-email.me> <s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at> <s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at> <s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com> <s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com> <s8522o$tol$1@dont-email.me>
<s85i3s$929$1@dont-email.me> <s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com> <sag7gi$9ur$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6d654e64-9393-4b58-9954-2b83e88d78e4n@googlegroups.com>
Subject: Re: Compact representation for common integer constants
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 17 Jun 2021 23:46:20 +0000
Content-Type: text/plain; charset="UTF-8"
 by: MitchAlsup - Thu, 17 Jun 2021 23:46 UTC

On Thursday, June 17, 2021 at 2:24:05 PM UTC-5, David Brown wrote:
> On 17/06/2021 20:22, MitchAlsup wrote:
> > On Thursday, June 17, 2021 at 12:38:33 PM UTC-5, Tim Rentsch wrote:
> >> Thomas Koenig <tko...@netcologne.de> writes:
> >>
> >>> Marcus <m.de...@this.bitsnbites.eu> schrieb:
> >>>
> >>>> A common source of
> >>>> errors is implicit type conversions in C, for instance.
> >>>
> >>> The integral promotions from signed to unsigned of the
> >>> same size are the worst.
> >>>
> >>> int a = -3;
> >>> unsigned int b = 2;
> >>> if (a > b)
> >>> printf ("You expected this to happen, right?\n");
> >>
> >> The C standard uses the term "integer promotions" rather than
> >> "integral promotions", but in any case what is going on here
> >> falls under the heading of "usual arithmetic conversions",
> >> not "integer promotions". (Integer promotions are things
> >> like turning a 'short' into an 'int'.)
> > <
> > What causes the supersize is that programmers are not taught
> > unsigned has a lower surprise factor than integer.
<
> unsigned types in C don't have "lower surprise factor" than signed
> types. They have slightly /different/ surprise factors. If you want to
> program in C, you should learn how the signed and unsigned integer types
> work, alone and together, and code accordingly.
<
While they do have different surprise factors, the unsigned variety is lower
because when signed an unsigned are mixed, the unsigned takes precedent.
<
And as I have stated many times: the only time I EVER use a signed type
is when at some point it has to contain a negative value. Then, again, if
it always contains a negative value (never positive) I STILL use unsigned
and subtract rather than add.
<
About the only time I use a signed integer type is when interfacing with a
library routine which has parameters or result defined as signed.
>
> There is a lot of value in using good static warning tools - enabling
> "-Wsign-compare -Wsign-conversion" in gcc will give you warnings on
> these things if you don't use explicit casts. You choose your own
> balance between reduced risk of errors at the cost of additional effort
> (such as casts) when you need to mixed signedness and know it is safe.
>
> One problem with a lot of C teaching is that it usually fails to teach
> about tools that can make programming easier and safer. Another is that
> if they teach the details of integer types at all, they do so with
> invalid and unhelpful generalisations like "unsigned types are better
> because overflow is defined and they are therefore safe".
> > <
> > But consider::
> > <
> > int64_t a = -3;
> > uint64_t b = 0xfffffffffffffffd;
> > if( a == b )
> > printf ("You expected this to happen, right?\n");
> >

Re: Compact representation for common integer constants

<sahece$ie$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17901&group=comp.arch#17901

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6322-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Fri, 18 Jun 2021 06:27:26 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sahece$ie$1@newsreader4.netcologne.de>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<bcd3dd9a-cfcd-4691-9163-842ddf1f483dn@googlegroups.com>
<s7u338$cek$1@newsreader4.netcologne.de> <s7v6j1$qns$1@dont-email.me>
<s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at>
<s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at>
<s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com>
<s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com>
<s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me>
<s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
Injection-Date: Fri, 18 Jun 2021 06:27:26 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6322-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6322:0:7285:c2ff:fe6c:992d";
logging-data="590"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 18 Jun 2021 06:27 UTC

MitchAlsup <MitchAlsup@aol.com> schrieb:
> On Thursday, June 17, 2021 at 12:38:33 PM UTC-5, Tim Rentsch wrote:
>> Thomas Koenig <tko...@netcologne.de> writes:
>>
>> > Marcus <m.de...@this.bitsnbites.eu> schrieb:
>> >
>> >> A common source of
>> >> errors is implicit type conversions in C, for instance.
>> >
>> > The integral promotions from signed to unsigned of the
>> > same size are the worst.
>> >
>> > int a = -3;
>> > unsigned int b = 2;
>> > if (a > b)
>> > printf ("You expected this to happen, right?\n");
>>
>> The C standard uses the term "integer promotions" rather than
>> "integral promotions", but in any case what is going on here
>> falls under the heading of "usual arithmetic conversions",
>> not "integer promotions". (Integer promotions are things
>> like turning a 'short' into an 'int'.)
><
> What causes the supersize is that programmers are not taught
> unsigned has a lower surprise factor than integer.
><
> But consider::
><
> int64_t a = -3;
> uint64_t b = 0xfffffffffffffffd;
> if( a == b )
> printf ("You expected this to happen, right?\n");

One of the blocks towards implementing unsigned integers in Fortran
was the discussion what to do when signed and unsigned integers
come together.

In Fortran, this being Formula Translation, it would probably make
sense to mandate comparision by value, so that

integer :: a
unsigned integer :: b

a = -3
b = 2_u ! How to specify an unsigned constant?

if (a> b) write (*,'(A)') "This should never happen"

would get the expected result. I think Sun Fortran had this.

Drawback? Not sufficiently C-like (with flashbacks to
http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html
) and one more instruction.

I considered writing up a proposal for Fortran standard,
but that would very probably go down in flames - there are
too many corner cases to get right, and too many details
that reasonable people can object to on reasonable grounds
whatever you chose.

Re: Compact representation for common integer constants

<saheha$ie$2@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17902&group=comp.arch#17902

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6322-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Fri, 18 Jun 2021 06:30:02 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <saheha$ie$2@newsreader4.netcologne.de>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s7u338$cek$1@newsreader4.netcologne.de> <s7v6j1$qns$1@dont-email.me>
<s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at>
<s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at>
<s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com>
<s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com>
<s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me>
<s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
<sag7gi$9ur$1@dont-email.me> <sag8p5$il8$1@dont-email.me>
Injection-Date: Fri, 18 Jun 2021 06:30:02 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6322-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6322:0:7285:c2ff:fe6c:992d";
logging-data="590"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 18 Jun 2021 06:30 UTC

Ivan Godard <ivan@millcomputing.com> schrieb:

> The warnings are necessary, but still annoying:
> for (int i = 0; i < arr.size(); i++)

Why chose arr.size() as unsigned?

As long as the types are long enough that overflow is not
an issue (as should be the case with 64-bit types), signed
has far nicer properties.

Re: Compact representation for common integer constants

<sahndn$l5s$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17906&group=comp.arch#17906

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Fri, 18 Jun 2021 11:01:42 +0200
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <sahndn$l5s$1@dont-email.me>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s7v6j1$qns$1@dont-email.me> <s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at>
<s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at>
<s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com>
<s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com>
<s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me>
<s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
<sag7gi$9ur$1@dont-email.me> <sag8p5$il8$1@dont-email.me>
<dde59e65-0dc9-489c-bb97-873248d2ff74n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Jun 2021 09:01:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="999e9651e969867b2f79d9d5e2984164";
logging-data="21692"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mrqAcEuPWactObgEscYFRDkyc+KQ2lc8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:lxlaR1wzHWe3qVXFHsUZg+ftfZQ=
In-Reply-To: <dde59e65-0dc9-489c-bb97-873248d2ff74n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Fri, 18 Jun 2021 09:01 UTC

On 18/06/2021 00:24, Quadibloc wrote:
> On Thursday, June 17, 2021 at 1:45:44 PM UTC-6, Ivan Godard wrote:
>
>> The warnings are necessary, but still annoying:
>> for (int i = 0; i < arr.size(); i++)
>

(I note that we are now in C++, rather than C.)

>> for example.
>
> ...because arr.size(), derived as it is from addresses, naturally
> has unsigned type. But this is surprising to programmers coming
> from languages that don't bother to provide the unsigned
> integer type.
>

Indeed, the return type of arr.size() is size_t - not only is it
unsigned, but it is often bigger than "int". On 64-bit systems, size_t
is typically going to be either "unsigned long" or "unsigned long long".
Thus the correct code is:

for (size_t i = 0; i < arr.size(); i++)

C++ has "auto", which can often be handy for avoiding having to specify
exact types. (Like many features, it can be useful but can also be abused.)

Unfortunately, if you write:

for (auto i = 0; i < arr.size(); i++)

then "i" gets the type of "0", which is of course "int".

You could do:

for (auto i = 0ull; i < arr.size(); i++)

or (expected for C++23) :

for (auto i = 0z; i < arr.size(); i++)

There is no good way in C++ to get a type based on the limits of a "for"
expression. This is possible, but rather ugly:

for (decltype(arr.size()) i = 0; i < arr.size(); i++)

But for such common cases, C++11 added a neat and convenient syntax:

for (auto& a : arr)

That is, presumably, what C++ programmers are taught now.

Re: Compact representation for common integer constants

<sahnmn$n6t$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17907&group=comp.arch#17907

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Compact representation for common integer constants
Date: Fri, 18 Jun 2021 11:06:30 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <sahnmn$n6t$1@dont-email.me>
References: <44003c05-8b05-4e0e-acb8-bb252be14d26n@googlegroups.com>
<s7u338$cek$1@newsreader4.netcologne.de> <s7v6j1$qns$1@dont-email.me>
<s7vn9p$bfu$1@newsreader4.netcologne.de>
<2021May18.183723@mips.complang.tuwien.ac.at>
<s80rjn$1ci$2@newsreader4.netcologne.de>
<2021May19.124934@mips.complang.tuwien.ac.at>
<s83h0k$jaj$1@newsreader4.netcologne.de>
<2021May19.214832@mips.complang.tuwien.ac.at> <s8414d$okc$1@dont-email.me>
<2021May20.001137@mips.complang.tuwien.ac.at> <s846ou$s25$1@dont-email.me>
<35c1d9c9-d12a-4812-bcac-07979e0fcaccn@googlegroups.com>
<s84b0a$lht$1@dont-email.me>
<5c8aa7d4-ae7d-465e-bcb4-230ee64b2bfbn@googlegroups.com>
<s8522o$tol$1@dont-email.me> <s85i3s$929$1@dont-email.me>
<s85j8h$hce$1@dont-email.me> <s869c0$nvg$1@dont-email.me>
<s86des$g1a$1@newsreader4.netcologne.de> <86zgvobdd4.fsf@linuxsc.com>
<4e106f2b-31a7-42ff-9523-cb396cbb80fdn@googlegroups.com>
<sag7gi$9ur$1@dont-email.me> <sag8p5$il8$1@dont-email.me>
<saheha$ie$2@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Jun 2021 09:06:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="999e9651e969867b2f79d9d5e2984164";
logging-data="23773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ptlnHPKlj92VPqxAtXMg+OofSTspcoDI="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:AJ0iY009YyqvabGASUIjEoJi9YA=
In-Reply-To: <saheha$ie$2@newsreader4.netcologne.de>
Content-Language: en-GB
 by: David Brown - Fri, 18 Jun 2021 09:06 UTC

On 18/06/2021 08:30, Thomas Koenig wrote:
> Ivan Godard <ivan@millcomputing.com> schrieb:
>
>> The warnings are necessary, but still annoying:
>> for (int i = 0; i < arr.size(); i++)
>
> Why chose arr.size() as unsigned?
>
> As long as the types are long enough that overflow is not
> an issue (as should be the case with 64-bit types), signed
> has far nicer properties.
>

arr.size() is of type size_t - it is an unsigned type. If C++ (since
this is C++ syntax, not common C syntax) had been invented now, in the
world of 64-bit machines, then perhaps size_t would have been signed.
But its roots go back to systems where you had 16-bit addresses and
memories that span the entire address space - an unsigned type for the
size of objects was not only logical but necessary.

I disagree somewhat on saying "signed has far nicer properties", just as
I disagree with people who say "unsigned" are "safer" or better defined.
The way they are defined in C and C++, they have somewhat /different/
properties, each of which can be useful in some circumstances.


devel / comp.arch / Re: Compact representation for common integer constants

Pages:123456789101112131415
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor