Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

19 May, 2024: Line wrapping has been changed to be consistent with Usenet standards.
 If you find that it is broken please let me know here rocksolid.nodes.help


devel / comp.arch / Re: Cray style vectors

SubjectAuthor
* A Very Bad IdeaQuadibloc
+- Re: A Very Bad IdeaChris M. Thomasson
+* Vectors (was: A Very Bad Idea)Anton Ertl
|+* Re: Vectors (was: A Very Bad Idea)Quadibloc
||+- Re: Vectors (was: A Very Bad Idea)Anton Ertl
||`- Re: VectorsMitchAlsup1
|`- Re: VectorsMitchAlsup1
+* Re: A Very Bad IdeaBGB
|`* Re: A Very Bad IdeaMitchAlsup1
| `- Re: A Very Bad IdeaBGB-Alt
+- Re: A Very Bad IdeaMitchAlsup1
+* Re: A Very Bad Idea?Lawrence D'Oliveiro
|`* Re: A Very Bad Idea?MitchAlsup1
| `- Re: A Very Bad Idea?BGB-Alt
`* Re: Cray style vectors (was: A Very Bad Idea)Marcus
 +* Re: Cray style vectors (was: A Very Bad Idea)Quadibloc
 |+- Re: Cray style vectors (was: A Very Bad Idea)Quadibloc
 |+* Re: Cray style vectors (was: A Very Bad Idea)Scott Lurndal
 ||`* Re: Cray style vectors (was: A Very Bad Idea)Thomas Koenig
 || `* Re: Cray style vectorsMitchAlsup1
 ||  `- Re: Cray style vectorsQuadibloc
 |`* Re: Cray style vectorsMarcus
 | +- Re: Cray style vectorsMitchAlsup1
 | `* Re: Cray style vectorsQuadibloc
 |  +- Re: Cray style vectorsQuadibloc
 |  +* Re: Cray style vectorsAnton Ertl
 |  |`* Re: Cray style vectorsStephen Fuld
 |  | +* Re: Cray style vectorsAnton Ertl
 |  | |+- Re: Cray style vectorsMitchAlsup1
 |  | |`* Re: Cray style vectorsStephen Fuld
 |  | | `* Re: Cray style vectorsMitchAlsup
 |  | |  `* Re: Cray style vectorsStephen Fuld
 |  | |   `* Re: Cray style vectorsTerje Mathisen
 |  | |    `* Re: Cray style vectorsAnton Ertl
 |  | |     +* Re: Cray style vectorsTerje Mathisen
 |  | |     |+- Re: Cray style vectorsMitchAlsup1
 |  | |     |+* Re: Cray style vectorsTim Rentsch
 |  | |     ||+* Re: Cray style vectorsMitchAlsup1
 |  | |     |||`* Re: Cray style vectorsTim Rentsch
 |  | |     ||| +* Re: Cray style vectorsOpus
 |  | |     ||| |`- Re: Cray style vectorsTim Rentsch
 |  | |     ||| +* Re: Cray style vectorsScott Lurndal
 |  | |     ||| |`- Re: Cray style vectorsTim Rentsch
 |  | |     ||| `* Re: Cray style vectorsMitchAlsup1
 |  | |     |||  `- Re: Cray style vectorsTim Rentsch
 |  | |     ||`* Re: Cray style vectorsTerje Mathisen
 |  | |     || `* Re: Cray style vectorsTim Rentsch
 |  | |     ||  `* Re: Cray style vectorsTerje Mathisen
 |  | |     ||   +* Re: Cray style vectorsTerje Mathisen
 |  | |     ||   |+* Re: Cray style vectorsMichael S
 |  | |     ||   ||`* Re: Cray style vectorsMitchAlsup1
 |  | |     ||   || `- Re: Cray style vectorsScott Lurndal
 |  | |     ||   |`- Re: Cray style vectorsTim Rentsch
 |  | |     ||   `- Re: Cray style vectorsTim Rentsch
 |  | |     |+- Re: Cray style vectorsAnton Ertl
 |  | |     |`* Re: Cray style vectorsDavid Brown
 |  | |     | +* Re: Cray style vectorsTerje Mathisen
 |  | |     | |+* Re: Cray style vectorsMitchAlsup1
 |  | |     | ||+* Re: Cray style vectorsAnton Ertl
 |  | |     | |||`* What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | ||| `* Re: What integer C type to use (was: Cray style vectors)David Brown
 |  | |     | |||  +* Re: What integer C type to use (was: Cray style vectors)Scott Lurndal
 |  | |     | |||  |`* Re: What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | |||  | +* Re: What integer C type to use (was: Cray style vectors)Scott Lurndal
 |  | |     | |||  | |+- Re: What integer C type to useMitchAlsup1
 |  | |     | |||  | |`* Re: What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | |||  | | `* Re: What integer C type to use (was: Cray style vectors)Scott Lurndal
 |  | |     | |||  | |  `* Re: What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | |||  | |   +- Re: What integer C type to use (was: Cray style vectors)Scott Lurndal
 |  | |     | |||  | |   `* Re: What integer C type to use (was: Cray style vectors)Tim Rentsch
 |  | |     | |||  | |    `* Re: What integer C type to use (was: Cray style vectors)Scott Lurndal
 |  | |     | |||  | |     `- Re: What integer C type to use (was: Cray style vectors)Tim Rentsch
 |  | |     | |||  | `- Re: What integer C type to useMitchAlsup1
 |  | |     | |||  +* Re: What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | |||  |+* Re: What integer C type to useMitchAlsup1
 |  | |     | |||  ||+- Re: What integer C type to useDavid Brown
 |  | |     | |||  ||`* Re: What integer C type to useTerje Mathisen
 |  | |     | |||  || `* Re: What integer C type to useTim Rentsch
 |  | |     | |||  ||  `* Re: What integer C type to useMitchAlsup1
 |  | |     | |||  ||   +- Re: What integer C type to useTim Rentsch
 |  | |     | |||  ||   `* Re: What integer C type to useDavid Brown
 |  | |     | |||  ||    `- Re: What integer C type to useThomas Koenig
 |  | |     | |||  |+* Re: What integer C type to use (was: Cray style vectors)David Brown
 |  | |     | |||  ||+* Re: What integer C type to use (was: Cray style vectors)Scott Lurndal
 |  | |     | |||  |||+* Re: What integer C type to use (was: Cray style vectors)Michael S
 |  | |     | |||  ||||+- Re: What integer C type to use (was: Cray style vectors)Scott Lurndal
 |  | |     | |||  ||||`- Re: What integer C type to use (was: Cray style vectors)David Brown
 |  | |     | |||  |||`- Re: What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | |||  ||`* Re: What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | |||  || `* Re: What integer C type to useDavid Brown
 |  | |     | |||  ||  `* Re: What integer C type to useMitchAlsup1
 |  | |     | |||  ||   `- Re: What integer C type to useDavid Brown
 |  | |     | |||  |`* Re: What integer C type to use (was: Cray style vectors)Thomas Koenig
 |  | |     | |||  | +* Re: What integer C type to useMitchAlsup1
 |  | |     | |||  | |+* Re: What integer C type to useDavid Brown
 |  | |     | |||  | ||`* Re: What integer C type to useMitchAlsup1
 |  | |     | |||  | || `* Re: What integer C type to useDavid Brown
 |  | |     | |||  | ||  `* Re: What integer C type to useMichael S
 |  | |     | |||  | ||   +* Re: What integer C type to useMitchAlsup1
 |  | |     | |||  | ||   |`* Re: What integer C type to useMichael S
 |  | |     | |||  | ||   | `* Re: What integer C type to useMitchAlsup1
 |  | |     | |||  | ||   `- Re: What integer C type to useThomas Koenig
 |  | |     | |||  | |`* Re: What integer C type to useThomas Koenig
 |  | |     | |||  | `* Re: What integer C type to use (was: Cray style vectors)Anton Ertl
 |  | |     | |||  +* Re: What integer C type to use (was: Cray style vectors)Brian G. Lucas
 |  | |     | |||  `- Re: What integer C type to useBGB
 |  | |     | ||+- Re: Cray style vectorsDavid Brown
 |  | |     | ||`- Re: Cray style vectorsTim Rentsch
 |  | |     | |+- Re: Cray style vectorsDavid Brown
 |  | |     | |`- Re: Cray style vectorsTim Rentsch
 |  | |     | `* Re: Cray style vectorsThomas Koenig
 |  | |     `* Re: Cray style vectorsBGB
 |  | `- Re: Cray style vectorsMitchAlsup1
 |  +- Re: Cray style vectorsBGB
 |  +* Re: Cray style vectorsMarcus
 |  `* Re: Cray style vectorsMitchAlsup1
 `* Re: Cray style vectors (was: A Very Bad Idea)Michael S

Pages:12345678910
Re: integer overflow

<l3uhksFbqddU1@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.arch
Subject: Re: integer overflow
Date: Sat, 24 Feb 2024 17:51:56 +0200
Organization: Tidorum Ltd
Lines: 24
Message-ID: <l3uhksFbqddU1@mid.individual.net>
References: <upq0cr$6b5m$1@dont-email.me> <uqpngc$3o4m9$3@dont-email.me>
<uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at>
<uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me>
<ur1h0v$emi4$1@newsreader4.netcologne.de>
<2024Feb20.091522@mips.complang.tuwien.ac.at>
<SW2BN.153110$taff.74839@fx41.iad> <ur2fq1$2ic6t$1@dont-email.me>
<ur2jvt$2j800$2@dont-email.me> <2024Feb20.194217@mips.complang.tuwien.ac.at>
<ur4rh6$350i7$1@dont-email.me> <20240221190916.00003551@yahoo.com>
<2024Feb24.123948@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net U6Dlbw8/eznYNkbf4DXBDQtgpviBuTl+yQXCBoGdDeJEnxS2D1
Cancel-Lock: sha1:Jup0j0C82rEisq3D7Jd/55ojFfQ= sha256:85Cq5e5reHTUs0zNa0eQGsB4qo/JjOJapqe7/ijCFoI=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <2024Feb24.123948@mips.complang.tuwien.ac.at>
 by: Niklas Holsti - Sat, 24 Feb 2024 15:51 UTC

On 2024-02-24 13:39, Anton Ertl wrote:
> Michael S <already5chosen@yahoo.com> writes:
>> On Wed, 21 Feb 2024 13:49:41 +0100 David Brown
>> <david.brown@hesbynett.no> wrote:
> [...]
>> However I don't think that "bonus" use of flags for bignum and
>> similar is any rarer on 64-bit machines than on 32-bit.
>
> I think Bignums are more common on 64-bit machines.

[...]

> I also think that general-purpose computers do more cryptography
> (and multi-precision arithmetic for that) than embedded computers.

Hm. That may depend on whether you are comnparing absolute numbers or
proportions of work-loads. Cryptography is very important for many
embedded systems (telecom, automatic teller machines, point-of-sale
terminals, etc.) Last I looked (several years ago), there were several
8051-based chips (small 8-bit processors) on the market with dedicated
on-chip HW accelerators for cryptography.

Re: integer overflow

<2024Feb24.180048@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: integer overflow
Date: Sat, 24 Feb 2024 17:00:48 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 29
Message-ID: <2024Feb24.180048@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur1h0v$emi4$1@newsreader4.netcologne.de> <2024Feb20.091522@mips.complang.tuwien.ac.at> <SW2BN.153110$taff.74839@fx41.iad> <ur2fq1$2ic6t$1@dont-email.me> <ur2jvt$2j800$2@dont-email.me> <2024Feb20.194217@mips.complang.tuwien.ac.at> <ur4rh6$350i7$1@dont-email.me> <20240221190916.00003551@yahoo.com> <2024Feb24.123948@mips.complang.tuwien.ac.at> <l3uhksFbqddU1@mid.individual.net>
Injection-Info: dont-email.me; posting-host="5f2d44315b30aefec1086248c3e53916";
logging-data="1381507"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rzZPbvKdk+jAs3QpkfRd3"
Cancel-Lock: sha1:THDLRoDfOWqMjO5AP1tREvgGIBk=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 24 Feb 2024 17:00 UTC

Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
>> I also think that general-purpose computers do more cryptography
>> (and multi-precision arithmetic for that) than embedded computers.
>
>
>Hm. That may depend on whether you are comnparing absolute numbers or
>proportions of work-loads.

I am thinking about the proportions of workloads.

>Cryptography is very important for many
>embedded systems (telecom, automatic teller machines, point-of-sale
>terminals, etc.) Last I looked (several years ago), there were several
>8051-based chips (small 8-bit processors) on the market with dedicated
>on-chip HW accelerators for cryptography.

And AMD64 and ARM A64 have acceleration instructions for symmetric
cryptographe (such as AES), too. Symmetric cryptography (with secret
keys only) does not use multi-precision arithmetic, but asymetric
cryptography (with public and private keys) does. I guess that there
is no special hardware for that because hardware that does it faster
than software would be very expensive, and because the asymmetric part
is only used at the start of a connection and when renewing the secret
key for the symmetric stuff.

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

Re: integer overflow

<2024Feb24.182125@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: integer overflow
Date: Sat, 24 Feb 2024 17:21:25 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 27
Message-ID: <2024Feb24.182125@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur1h0v$emi4$1@newsreader4.netcologne.de> <2024Feb20.091522@mips.complang.tuwien.ac.at> <SW2BN.153110$taff.74839@fx41.iad> <ur2fq1$2ic6t$1@dont-email.me> <ur2jvt$2j800$2@dont-email.me> <2024Feb20.194217@mips.complang.tuwien.ac.at> <ur4rh6$350i7$1@dont-email.me> <20240221190916.00003551@yahoo.com> <2024Feb24.123948@mips.complang.tuwien.ac.at> <GInCN.92986$Sf59.46917@fx48.iad>
Injection-Info: dont-email.me; posting-host="5f2d44315b30aefec1086248c3e53916";
logging-data="1381507"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EaEBPfv6k4Tt2j1jdUXQC"
Cancel-Lock: sha1:kT+8z9eCZe+Flqel5zFx23HVOTE=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 24 Feb 2024 17:21 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>Michael S <already5chosen@yahoo.com> writes:
>
>>
>>On ARM cores the number of physical flags registers is roughly 1/3 of
>>the nymber of physical integer registers (46 vs. 147 on A710, 39
>>vs. 120 on Neoverse N1/A76
>><https://chipsandcheese.com/2023/08/11/arms-cortex-a710-winning-by-default/>,
>>but I guess that this is due to being able to suppress flags updates
>>rather than ignoring those that are overwritten without being read.
>>
>>That assumes that all of A32, T32, and A64 have the ability to
>>suppress flags updates. Do they?
>
>A32, T32 and A64 have an bit in the instruction word that
>specifies whether the flags should be updated. T16
>only updates flags when the instruction is in an if-then (IT)
>block.

What is T16? Google does not give me anything appropriate for "ARM
T16"? Do you mean the 16-bit-encoded instructions in T32?

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

Re: What integer C type to use

<86a5npwyxo.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: What integer C type to use
Date: Sat, 24 Feb 2024 09:32:19 -0800
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <86a5npwyxo.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <2024Feb20.184737@mips.complang.tuwien.ac.at> <cc04a47d7852ec7370386cc579a66e36@www.novabbs.org> <ur4t1g$35evo$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="1cdea6df135853ae187447ca49a96387";
logging-data="1386163"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bcAE4bv+2N0gDyeMrrHrUTogNIlNFbuY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:PTtERR3QhnLyPvNZko69FIDhNn8=
sha1:VWLUomLCpQufEOnkNHzcQIaTTKo=
 by: Tim Rentsch - Sat, 24 Feb 2024 17:32 UTC

Terje Mathisen <terje.mathisen@tmsw.no> writes:

> MitchAlsup1 wrote:
[...]
>> The semantics of unsigned are better when you are twiddling bits than
>> when signed. My programming practice is to use unsigned everywhere that
>> a negative number is unexpected.
>
> Ditto.

10-4.

It always surprises me to encounter people who think signed types
should be the default, with almost no exceptions. It's one thing
to be somewhat cavalier about shooting yourself in the foot, it's
quite another to deliberately choose a large caliber weapon ahead
of time.

Re: What integer C type to use (was: Cray style vectors)

<2024Feb24.182641@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: What integer C type to use (was: Cray style vectors)
Date: Sat, 24 Feb 2024 17:26:41 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 19
Message-ID: <2024Feb24.182641@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <2024Feb20.184737@mips.complang.tuwien.ac.at> <ur4kbv$330qg$1@dont-email.me> <nSnBN.514349$83n7.273352@fx18.iad>
Injection-Info: dont-email.me; posting-host="5f2d44315b30aefec1086248c3e53916";
logging-data="1381507"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GE3RLAy8NjyRSC4rtXkPG"
Cancel-Lock: sha1:rcoF2yz/+3SU7VpJK+kJmJCHcLk=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 24 Feb 2024 17:26 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
>David Brown <david.brown@hesbynett.no> writes:
>>On 20/02/2024 18:47, Anton Ertl wrote:
>
>>And support for 32-bit has /not/ been "eliminated from ARM cores". It
>>may have been eliminated from the latest AArch64 cores
>
>The ARMv8 architecture fully supports the A32 and T32 instruction sets.

There is no ARMv8 architecture. ARMv8-M does not support A64.
ARMv8-A and ARMv8-R do. They may also support A32 and T32, but then
the A cores released since 2021 (X2 and following, A710 and following,
A510 and following) are ARMv9-A, not ARMv8-A; and several of them do
not support A32 nor T32.

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

Re: integer overflow

<2024Feb24.183726@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: integer overflow
Date: Sat, 24 Feb 2024 17:37:26 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 112
Message-ID: <2024Feb24.183726@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur1h0v$emi4$1@newsreader4.netcologne.de> <2024Feb20.091522@mips.complang.tuwien.ac.at> <SW2BN.153110$taff.74839@fx41.iad> <ur2fq1$2ic6t$1@dont-email.me> <ur2jvt$2j800$2@dont-email.me> <2024Feb20.194217@mips.complang.tuwien.ac.at> <ur4rh6$350i7$1@dont-email.me>
Injection-Info: dont-email.me; posting-host="5f2d44315b30aefec1086248c3e53916";
logging-data="1406322"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JeinC/HbdBJd73IcdT3rE"
Cancel-Lock: sha1:6wAEp783EwSUuc/Ba4JgdnOU8sw=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 24 Feb 2024 17:37 UTC

David Brown <david.brown@hesbynett.no> writes:
>On 20/02/2024 19:42, Anton Ertl wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 20/02/2024 16:17, Terje Mathisen wrote:
>>>> x86 has had an 'O' (Overflow) flags bit since the very beginning, along
>>>> with JO and JNO for Jump on Overflow and Jump if Not Overflow.
>>>>
>>>
>>> Many processors had something similar. But I think they fell out of
>>> fashion for 64-bit RISC,
>>
>> No, it didn't. All the RISCs that had flags registers for their
>> 32-bit architectures still have it for their 64-bit architectures.
>>
>
>I was thinking more in terms of /using/ these flags, rather than ISA
>support for them. ISAs would clearly have to keep the flag registers
>and the instructions that used them if they wanted to keep compatibility
>with 32-bit code.

64-bit architectures of this century have separate 64-bit instruction
sets on which you cannot run 32-bit code. The idea of having a 32-bit
instruction set that's a subset of the 64-bit instruction set, and
supporting both 32-bit programs and 64-bit programs without mode
switch seems to have gone out of fashion; it used to be in fashion in
the 1990s when MIPS, SPARC, and PowerPC introduced 64-bit extensions
by just adding instructions to their 32-bit instruction set (and
defining what the 32-bit instructions do with the additional bits in
the GPRs). So if AMD and ARM had thought that they would be better
off in the long term without flags, they could have designed AMD64 and
A64 to work without flags.

>But I think it was fairly rare to use the "add 32-bit and update flags"
>instruction in 32-bit RSIC systems (except for 64-bit arithmetic), and
>much rarer to use the "add 64-bit and update flags" version in 64-bit
>versions.

On ARM A64's glibc-2.31:

[a76:/usr/lib/aarch64-linux-gnu:99372] objdump -d libc-2.31.so |grep '\<add\>'|wc -l
19330
[a76:/usr/lib/aarch64-linux-gnu:99373] objdump -d libc-2.31.so |grep '\<adds\>'|wc -l
277

However, glibc is written in C. If you look at code for a language
with Bignums, I expect that things look quite differently.

>> No, it isn't, as demonstrated by the fact that architectures with
>> flags registers (AMD64, ARM A64) handily outperform architectures
>> without (but probably not because they have a flags register).
>
>I think it would mainly be /despite/ having a flag register, rather than
>/because/ of it?

There is no evidence for "despite".

>Sometimes having flags for overflows, carries, etc., can be very handy.
>So having it in the ISA is useful. But I think you would normally want
>your code to avoid setting or reading flags.

If each instruction can specify whether it sets flags or not, that
costs one bit per instruction, which is also a cost.

AMD64 does not spend that bit, and I see no evidence that its
performance suffers from setting flags too often.

>It would, I think, be particularly cumbersome to track several parallel
>actions that all act on the flag register, as it is logically a shared
>resource.

Not particularly. The renamer ensures that the instructions write to
different physical flags registers, and that instructions that read
flags read the right physical register.

>Do you think it is an advantage for a RISC architecture to have a flags
>register compared to alternatives?

I think my alternative of putting carry and overflow in the result
register has certain advantages.

If you compare a RISC with a flags register (such as A64) to RV64GC,
certainly the add-with-carry-in-carry-out is 1 instruction (with
typically 1 cycle latency) in A64 and 5 (with typically 3 cycles
latency) in RV64GC; and the overflow check in the fast path for a
Bignum addition is 2 instructions longer than on A64.

>> That's nonsense. People use carry for implementing multi-precision
>> arithmetic (e.g., for cryptography) and for Bignums, and they use
>> overflow for implementing Bignums. And the significance of these
>> features has increased over time.
>>
>
>Fair enough, you do want carry (or an equivalent) for big number work.
>But I would still contend that the vast majority of integers and integer
>arithmetic used in code will fit within 32 bits, and the vast majority
>of those that don't, will fit within 64 bits.

Sure. But with Bignums, you have to check for overflow after every
addition, subtraction, or multiplication. Actually, you need a check
even with division: The result of dividing the smallest small Bignum
by -1 does not fit in a small Bignum.

>Once you go beyond that,
>you will need lots of bits (such as, as you say, cryptography).

Yes, so you need multi-precision arithmetic on 64-bit systems just as
on 32-bit systems.

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

Re: integer overflow

<20240224202216.00006c56@yahoo.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5...@yahoo.com (Michael S)
Newsgroups: comp.arch
Subject: Re: integer overflow
Date: Sat, 24 Feb 2024 20:22:16 +0200
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20240224202216.00006c56@yahoo.com>
References: <upq0cr$6b5m$1@dont-email.me>
<uqqvkc$i2cu$1@dont-email.me>
<uqvk2o$1snbf$1@dont-email.me>
<ur1h0v$emi4$1@newsreader4.netcologne.de>
<2024Feb20.091522@mips.complang.tuwien.ac.at>
<SW2BN.153110$taff.74839@fx41.iad>
<ur2fq1$2ic6t$1@dont-email.me>
<ur2jvt$2j800$2@dont-email.me>
<2024Feb20.194217@mips.complang.tuwien.ac.at>
<ur4rh6$350i7$1@dont-email.me>
<20240221190916.00003551@yahoo.com>
<2024Feb24.123948@mips.complang.tuwien.ac.at>
<GInCN.92986$Sf59.46917@fx48.iad>
<2024Feb24.182125@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="1bc486a1a659dff3934535177cd44eb3";
logging-data="1400268"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sLAv2dGcGXw+pUmJqUSKzvZwctGHSY64="
Cancel-Lock: sha1:aQypgYI4ZoJMpHDdwsIh5WHI+2o=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)
 by: Michael S - Sat, 24 Feb 2024 18:22 UTC

On Sat, 24 Feb 2024 17:21:25 GMT
anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:

> scott@slp53.sl.home (Scott Lurndal) writes:
> >anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> >>Michael S <already5chosen@yahoo.com> writes:
> >
> >>
> >>On ARM cores the number of physical flags registers is roughly 1/3
> >>of the nymber of physical integer registers (46 vs. 147 on A710, 39
> >>vs. 120 on Neoverse N1/A76
> >><https://chipsandcheese.com/2023/08/11/arms-cortex-a710-winning-by-default/>,
> >>but I guess that this is due to being able to suppress flags updates
> >>rather than ignoring those that are overwritten without being read.
> >>
> >>That assumes that all of A32, T32, and A64 have the ability to
> >>suppress flags updates. Do they?
> >
> >A32, T32 and A64 have an bit in the instruction word that
> >specifies whether the flags should be updated. T16
> >only updates flags when the instruction is in an if-then (IT)
> >block.
>
> What is T16? Google does not give me anything appropriate for "ARM
> T16"? Do you mean the 16-bit-encoded instructions in T32?
>
> - anton

Scott probably uses a name T16 for pre-ARMv7 variant of Thumb.

Re: Cray style vectors

<8634thwwgh.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sat, 24 Feb 2024 10:25:50 -0800
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <8634thwwgh.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqge2p$279ql$1@dont-email.me> <uqhiqb$2grub$1@dont-email.me> <uqlm2c$3e9bp$1@dont-email.me> <uqmn7c$3n35k$1@dont-email.me> <2024Feb16.082736@mips.complang.tuwien.ac.at> <uqnmue$3o4m9$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="1cdea6df135853ae187447ca49a96387";
logging-data="1408952"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/virUIKwmzHyor4wXk3Z9dMF8qu8BxSVg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:uQdFRUsVDVikSyK2eNQ4lIY6gM0=
sha1:gUcOF6uPrcf8RAXv1jJybnK8dJY=
 by: Tim Rentsch - Sat, 24 Feb 2024 18:25 UTC

Terje Mathisen <terje.mathisen@tmsw.no> writes:

> David Brown wrote:
>
>> On 17/02/2024 19:58, Terje Mathisen wrote:
>>
>>> Anton Ertl wrote:
>>>
>>>> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>>>>
>>>>> On the third (i.e gripping) hand you could have a language like
>>>>> Java where it would be illegal to transform a temporarily
>>>>> trapping loop into one that would not trap and give the
>>>>> mathematically correct answer.
>>>>
>>>> What "temporarily trapping loop" and "mathematically correct
>>>> answer"?
>>>>
>>>> If you are talking about integer arithmetic, the limited integers
>>>> in Java have modulo semantics, i.e., they don't trap, and
>>>> BigIntegers certainly don't trap.
>>>>
>>>> If you are talking about FP (like I did), by default FP addition
>>>> does not trap in Java, and any mention of "mathematically
>>>> correct" in connection with FP needs a lot of further
>>>> elaboration.
>>>
>>> Sorry to be unclear:
>>
>> I haven't really been following this thread, but there's a few
>> things here that stand out to me - at least as long as we are
>> talking about C.
>
> I realized a bunch of messages ago that it was a bad idea to write
> (pseudo-)C to illustrate a general problem. :-(
>
> If we have a platform where the default integer size is 32 bits
> and long is 64 bits, then afaik the C promotion rules will use int
> as the accumulator size, right?

For a signed type T, a C implementation is free to hold values of
type T in any memory cell that is at least as wide as T, and in
particular can hold a 32-bit int in a 64-bit register, if it so
chooses. More specifically, an implementation may translate a
statement like (assume x and y are 32-bit ints)

x = x + y;

using a 64-bit add, and store the full 64-bit result into a
64-bit register that corresponds to x. Note that what causes the
problem is not the store of a large result but the addition that
overflows the nominal 32-bit type. As long as the results of the
addition are in range, everything is fine; but once any of the
additions overflows the nominal 32-bit range, all bets are off.

> What I was trying to illustrate was the principle that by having a
> wider accumulator you could aggregate a series of numbers, both
> positive and negative, and get the correct (in-range) result, even
> if the input happened to be arranged in such a way that it would
> temporarily overflow the target int type.
>
> I think it is much better to do it this way and then get a
> conversion size trap at the very end when/if the final sum is in
> fact too large for the result type.

Absolutely, and for the accumulator choose the widest signed type
available. At the tail end of the loop, the final value can (and
should?) be ranged checked, because storing an out-of-range value
into a smaller type is a "safe" operation in that what happens is
implementation-defined behavior, so it's very likely nothing very
bad will happen (at least not right away ;).

Re: Cray style vectors

<86y1b9vhax.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sat, 24 Feb 2024 10:38:30 -0800
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <86y1b9vhax.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqge2p$279ql$1@dont-email.me> <uqhiqb$2grub$1@dont-email.me> <uqlm2c$3e9bp$1@dont-email.me> <uqmn7c$3n35k$1@dont-email.me> <2024Feb16.082736@mips.complang.tuwien.ac.at> <uqnmue$3o4m9$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="1cdea6df135853ae187447ca49a96387";
logging-data="1414111"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tn6edevs/+hzu+rCMXgngw0AsxJ/CXJQ="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:TYEXP5hx9KDpopvCG8YB2zewmyc=
sha1:ayo6pAPVCBrx+SPVYw8XxvwgAmU=
 by: Tim Rentsch - Sat, 24 Feb 2024 18:38 UTC

mitchalsup@aol.com (MitchAlsup1) writes:

> Terje Mathisen wrote:
>
>> If we have a platform where the default integer size is 32 bits
>> and long is 64 bits, then afaik the C promotion rules will use
>> int as the accumulator size, right?
>
> Not necessarily:: accumulation rules allow the promotion of
> int->long inside a loop

Yes.

> if the long is smashed back to int immediately after the loop
> terminates.

Doing this may be a good idea, but the C standard doesn't require
it. Once the horse is out of the barn, as far as the standard is
concerned there nothing that forces an implementation to evidence
any concern about getting the horse back inside.

In particular, an implementation may continue holding a 32-bit int
in a 64-bit memory for the rest of the program's execution, making
use of all 64 bits in any subsequent operations, and not run afoul
of what the standard requires.

Re: What integer C type to use

<452f33678746bc9bfa7296ca1fe77a18@www.novabbs.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchal...@aol.com (MitchAlsup1)
Newsgroups: comp.arch
Subject: Re: What integer C type to use
Date: Sat, 24 Feb 2024 18:48:37 +0000
Organization: Rocksolid Light
Message-ID: <452f33678746bc9bfa7296ca1fe77a18@www.novabbs.org>
References: <upq0cr$6b5m$1@dont-email.me> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <2024Feb20.184737@mips.complang.tuwien.ac.at> <cc04a47d7852ec7370386cc579a66e36@www.novabbs.org> <ur4t1g$35evo$1@dont-email.me> <86a5npwyxo.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="3988088"; mail-complaints-to="usenet@i2pn2.org";
posting-account="PGd4t4cXnWwgUWG9VtTiCsm47oOWbHLcTr4rYoM0Edo";
User-Agent: Rocksolid Light
X-Rslight-Posting-User: ac58ceb75ea22753186dae54d967fed894c3dce8
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$C7cEkJggBfb9GoigM/np5eQwfMcBjR3T.LlwQft87T9OwKFjl2gk6
 by: MitchAlsup1 - Sat, 24 Feb 2024 18:48 UTC

Tim Rentsch wrote:

> 10-4.

> It always surprises me to encounter people who think signed types
> should be the default, with almost no exceptions. It's one thing
> to be somewhat cavalier about shooting yourself in the foot, it's
> quite another to deliberately choose a large caliber weapon ahead
> of time.

I am of the opinion that the proper default type is unsigned--the
only reason to use a singed type is if at some point in it life it
needs to hold a negative number.

With C-promotions, unsigned is safer when mixing signed and unsigned.

Re: What integer C type to use (was: Cray style vectors)

<2024Feb24.215717@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: What integer C type to use (was: Cray style vectors)
Date: Sat, 24 Feb 2024 20:57:17 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 180
Message-ID: <2024Feb24.215717@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <2024Feb20.184737@mips.complang.tuwien.ac.at> <ur4kbv$330qg$1@dont-email.me>
Injection-Info: dont-email.me; posting-host="5f2d44315b30aefec1086248c3e53916";
logging-data="1509106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1864RI9qt+Ma3aMByRTyp+d"
Cancel-Lock: sha1:SWd9qCzZL5vlsCmHWlbT8QoMgs8=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 24 Feb 2024 20:57 UTC

David Brown <david.brown@hesbynett.no> writes:
>On 20/02/2024 18:47, Anton Ertl wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 20/02/2024 13:00, Anton Ertl wrote:
>>>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>>> mitchalsup@aol.com (MitchAlsup1) writes:
>Another possible reason is that it is very useful to have integer types
>with sizes 1, 2, 4 and 8 bytes. C doesn't have many standard integer
>types, so if "int" is 64-bit, you have "short" as either 16-bit and have
>no 32-bit type, or "short" is 32-bit and you have no 16-bit type. With
>32-bit "int", it's easy to have each size without having to add extended
>integer types or add new standard integer types (like "short short int"
>for 16-bit and "short int" for 32-bit).

short had been 16-bit on 16-bit machines and on 32-bit machines, so
the right choice for 64-bit machines is to make it 16-bit, too. As
for a 32-bit type, that would then obviously be "long short". The C
compiler people had no qualms at adding "long long" when they wanted
something bigger then 32 bits on 32-bit systems, so what should keep
them from adding "long short"?

>I saw benchmarks showing x32 being measurably faster,

Sure, it's measurably faster. That's obviously not sufficient for
incurring the cost of x32.

>but it's not
>unlikely that the differences got less with more modern x86-64
>processors (with bigger caches)

Doubtful. The L1 caches have not become bigger since the days of the
K7 (1999) with its 64KB D and I caches (and the K7 actually did not
support AMD64). There has been some growth in L2+L3 combined in
recent years, but x32 already flopped earlier.

>and it's simply not worth the effort
>having another set of libraries and compiler targets just to make some
>kinds of code marginally faster.

Exactly.

>And support for 32-bit has /not/ been "eliminated from ARM cores".

Of course it has. E.g., the Cortex-X1 supports A32/T32, and its
descendants Cortex-X2, X3, X4 don't. The Cortex-A710 supports
A32/T32, it's successors A715 and A720 do not. Cortex-A510 supports
A32/T32, A520 doesn't.

>It
>may have been eliminated from the latest AArch64 cores - I don't keep
>good track of these. But for every such core sold, there will be
>hundreds (my guestimate) of 32-bit ARM cores sold in microcontrollers
>and embedded systems.

Irrelevant for the question at hand: Are the performance benefits of
32-bit applications sufficient to pay for the cost of maintaining a
32-bit software infrastructure on an otherwise 64-bit system? The
answer is no.

>>> I would suggest C "fast" types like int_fast32_t (or other "fast" sizes,
>>> picked to fit the range you need).
>>
>> Sure, and then the program might break when an array has more the 2^31
>> elements; or it might work on one platform and break on another one.
>>
>
>You need to pick the appropriate size for your data, as I said.

In general-purpose computing, you usually don't know that size. E.g.,
for a sort routine, do you use int_fast32_t, int_fast8_t,
int_fast16_t, or int_fast64_t for the array size?

>> By contrast, with (u)intptr_t, on modern architectures you use the
>> type that's as wide as the GPRs. And I don't see a reason why to use
>> something else for a loop counter.
>
>I like my types to say what they mean. "uintptr_t" says "this object
>holds addresses for converting pointer values back and forth with an
>integer type".

Exactly. It's the unnamed type of BCPL and B, and the int of Unix C
before the I32LP64 mistake.

>Nonetheless, it is good design to use appropriate type names for
>appropriate usage. This makes the code clearer, and increases portability.

On the contrary, in the Gforth project we have had many more
portability problems with C code with its integer type zoo than in the
Forth code which just has single-cell (a machine word), double cell,
and char as integer types. Likewise, Forth code from others tends to
be pretty portable between 32-bit and 64-bit systems, even if the code
has only been tested on one kind of system.

>> As for int64_t, that tends to be
>> slow (if supported at all) on 32-bit platforms, and it is more than
>> what is necessary for indexing arrays and for loop counters that are
>> used for indexing into arrays.
>>
>
>And that is why it makes sense to use the "fast" types. If you need a
>16-bit range, use "int_fast16_t". It will be 64-bit on 64-bit systems,
>32-bit on 32-bit systems, and 16-bit on 16-bit and 8-bit systems -
>always supporting the range you need, as fast as possible.

That makes no sense. E.g., an in-memory sorting routine might well
have to sort 100G elements or more on a suitably large (64-bit)
machine. So according you one should use int_fast64_t. But that
would be slow and unnecessarily large on a 32-bit system where you
cannot hold and sort that many items anyway.

>>> Don't use "-fwrapv" unless you actually need it - in most
>>> code, if your arithmetic overflows, you have a mistake in your code, so
>>> letting the compiler assume that will not happen is a good thing.
>>
>> Thank you for giving a demonstration for Scott Lurndal. I assume that
>> you claim to be a programmer.
>>
>
>Sorry, that comment went over my head - I don't know what
>"demonstration" you are referring to.

I wrote in <2024Feb20.091522@mips.complang.tuwien.ac.at>:
|Those ideas are that integer overflows do not happen and that a
|competent programmer proactively prevents them from happening, by
|sizing the types accordingly, and checking the inputs.

Scott Lurndal replied <SW2BN.153110$taff.74839@fx41.iad>:
|Can't say that I've known a programmer who thought that way.

>For comparison to C, look at the Zig language. (It's not a language I
>have used or know in detail, but I know a little about it.) Unsigned
>integer arithmetic overflow is UB in Zig, just like signed integer
>arithmetic overflow. There are standard options and block settings
>(roughly equivalent to pragmas) to control whether these give a run-time
>error, or are assumed never to happen (for optimisation purposes). And
>if you want to add "x" and "y" with wrapping, you use "x +% y" as an
>explicit choice of operator.
>
>That seems to me to be the right approach for an efficient high-level
>language.

I don't know about Zig, but for a language like C, I would prefer
types that ask for trap-on-overflow arithmetic, or for modulo
arithmetic instead of introducing an additional operator.

The undefined option is just a bad idea: Wang et al
<https://people.eecs.berkeley.edu/~akcheung/papers/apsys12.pdf> found
that it gave a measurable speedup over -fwrapv in only one loop in
SPECint2006, and that speedup is only due to the I32LP64 mistake.
I.e., a competently designed dialect would not have that mistake, and
there would be no measurable speedup from the undefined option, just
the possibility of the compiler doing something unexpected.

>If you want "int z = x + y;" with wrapping, write :
>
> int z = (unsigned) x + (unsigned) y;

I'll leave that to you, not just for the following reason:

Once upon a time someone like you suggested using some casting
approach for getting x-1>=x (with signed x) to work as intended. I
tried it, and the result was that gcc-3.something still "optimized" it
to false.

>And even then, I always put it in a
>pragma so that the code works even if someone uses different compiler flags.

Yes, announcing such things in the source code is a good idea in
principle. In practice newer versions of gcc tend to need more sanity
flags (the default of newer gccs is more insanity), and the older
versions do not understand the new flags and fail if you pass them.
So we check every sanity flag in autoconf and use those that the gcc
version used accepts. Doing that through pragmas filled in by
configure does not seem to be any better than using flags through the
Makefile.

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

Re: What integer C type to use (was: Cray style vectors)

<2024Feb24.232901@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: What integer C type to use (was: Cray style vectors)
Date: Sat, 24 Feb 2024 22:29:01 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 17
Message-ID: <2024Feb24.232901@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <gq4BN.90773$Sf59.78868@fx48.iad> <2024Feb20.192740@mips.complang.tuwien.ac.at> <HQ6BN.120060$STLe.3128@fx34.iad> <2024Feb20.225455@mips.complang.tuwien.ac.at> <29aBN.495740$83n7.231444@fx18.iad>
Injection-Info: dont-email.me; posting-host="5f2d44315b30aefec1086248c3e53916";
logging-data="1509106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JI+JpN5o0g+pc1wUE7jJQ"
Cancel-Lock: sha1:H9ewFW+G/FHQz245r+o0seC44rQ=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 24 Feb 2024 22:29 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>scott@slp53.sl.home (Scott Lurndal) writes:
>>>The Unix code ported relatively easily to I32LP64 because uintptr_t
>>>had been used extensively rather than assumptions about
>>>sizeof(int) == sizeof(int *).
....
>Sorry, I meant ptrdiff_t, which was used for pointer math.

I have seen little code that uses ptrdiff_t; quite a bit that used
size_t (the unsigned brother of ptrdiff_t). But my memory tells me
that even size_t was not very widespread in 1995.

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

Re: integer overflow (was: Cray style vectors)

<2024Feb24.233358@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: integer overflow (was: Cray style vectors)
Date: Sat, 24 Feb 2024 22:33:58 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 12
Message-ID: <2024Feb24.233358@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <2024Feb20.091522@mips.complang.tuwien.ac.at> <SW2BN.153110$taff.74839@fx41.iad> <2024Feb20.173916@mips.complang.tuwien.ac.at> <ur2vfp$31a6$1@gal.iecc.com>
Injection-Info: dont-email.me; posting-host="5f2d44315b30aefec1086248c3e53916";
logging-data="1509106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1848QsSRHjpI3bb9Ws9zxQk"
Cancel-Lock: sha1:7FEGHpzXuqpWS3rYmqgFBg288sk=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 24 Feb 2024 22:33 UTC

John Levine <johnl@taugh.com> writes:
>There weren't instructions to do add or subtract with
>carry but it was pretty easy to fake by doing a branch on no carry
>around an instruction to add or subtract 1.

That is sufficient for double-word arithmetic, but not for multi-word
arithmetic. ESA/390 adds addition-with-carry-in.

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

Re: Cray style vectors

<86ttlxv5y5.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sat, 24 Feb 2024 14:43:46 -0800
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <86ttlxv5y5.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqge2p$279ql$1@dont-email.me> <uqhiqb$2grub$1@dont-email.me> <uqlm2c$3e9bp$1@dont-email.me> <uqmn7c$3n35k$1@dont-email.me> <2024Feb16.082736@mips.complang.tuwien.ac.at> <uqnmue$3o4m9$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <86y1biy874.fsf@linuxsc.com> <02d4b67c9c2a4807b655ba503240279e@www.novabbs.org> <86h6i6xvxq.fsf@linuxsc.com> <8a42db6eafb8ebf769763a572bd9cc3a@www.novabbs.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="1cdea6df135853ae187447ca49a96387";
logging-data="1515847"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+h9lBnS4arAMBO1pBf1oh+JAYujILlPdQ="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:baZYFCSqST87ZuZIM0m5dsGthM4=
sha1:C0qOLWxOEq8yh2xtt/G3DrVyWOk=
 by: Tim Rentsch - Sat, 24 Feb 2024 22:43 UTC

mitchalsup@aol.com (MitchAlsup1) writes:

> Tim Rentsch wrote:
>
>> mitchalsup@aol.com (MitchAlsup1) writes:
>>
>>> Tim Rentsch wrote:
>>>
>>>> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>>>>
>>>>> [...]
>>>>>
>>>>> int8_t sum(int len, int8_t data[])
>>>>> {
>>>>> int s = 0;
>>>>> for (unsigned i = 0 i < len; i++) {
>>>>> s += data[i];
>>>>> }
>>>>> return (int8_t) s;
>>>>> }
>>>>
>>>> The cast in the return statement is superfluous.
>>>
>>> But the return statement is where overflow (if any) is detected.
>>
>> The cast is superfluous because a conversion to int8_t will be
>> done in any case, since the return type of the function is
>> int8_t.
>
> Missing my point:: which was::
>
> The summation loop will not overflow, and overflow is detected at
> the smash from int to int8_t.

So you wanted to make a point that's completely unrelated to what I
was saying?

In any case the conversion from type int to type int8_t that is
done after loop is finished is not going to detect any overflow,
regardless of whether it is done by an explicit cast or implicitly
by the return statement. Converting an out-of-range value to a
signed integer type is merely implementation-defined behavior. As
of C99 the C standard allows a signal to be raised in such cases,
but TTBOMK no implementations actually do that (and AFAICT neither
clang nor gcc even have an option to do so).

Re: Cray style vectors

<86plwluvy8.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sat, 24 Feb 2024 18:19:43 -0800
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <86plwluvy8.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqge2p$279ql$1@dont-email.me> <uqhiqb$2grub$1@dont-email.me> <uqlm2c$3e9bp$1@dont-email.me> <uqmn7c$3n35k$1@dont-email.me> <2024Feb16.082736@mips.complang.tuwien.ac.at> <uqnmue$3o4m9$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <86y1biy874.fsf@linuxsc.com> <uqsm01$10b29$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="d0a541e28d41d50395e069f34372e044";
logging-data="1597243"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vtr6cqvSYCFCrAIwHYObav59O5P1BDYc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:xXOF5Y6rm1HDMBQVVC4cjyfo4VE=
sha1:qAfG9m0WZEUgNWBdbV8g93kex0s=
 by: Tim Rentsch - Sun, 25 Feb 2024 02:19 UTC

Terje Mathisen <terje.mathisen@tmsw.no> writes:

> Tim Rentsch wrote:
>
>> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>>
>>> [...]
>>>
>>> int8_t sum(int len, int8_t data[])
>>> {
>>> int s = 0;
>>> for (unsigned i = 0 i < len; i++) {
>>> s += data[i];
>>> }
>>> return (int8_t) s;
>>> }
>>
>> The cast in the return statement is superfluous.
>
> I am normally writing Rust these days, where UB is far less common,
> but casts like this are mandatory.

Oh. I didn't know that about Rust. Interesting.

I'm always somewhat surprised when someone advocates using a cast
for such things, and now more surprised to learn that Rust has
chosen to impose using a cast as part of its language rules. I
understand that it has the support of community sentiment, but
even so it seems like a poor choice here. I'm not a big fan of
the new attribute syntax, but a form like

return [[narrow]] s;

looks to be a better way of asking Rust to allow what is a
normally disallowed conversion. By contrast, using a cast is
overkill. There is unnecessary redundancy, by specifying a type
in two places, and the risk that they might get out of sync. And
on general principles requiring a cast violates good security
principles. If someone needs access to a particular room in a
building, we don't hand over a master key that opens every room
in the building. If someone needs to read some documents that
have classified materials, we don't give them an access code that
lets them read any sensitive material regardless of whether it's
relevant. Maybe Rust is different, but in C a cast allows any
conversion that is possible in the language, even the unsafe
ones. It just seems wrong to use the nuclear option of casting
for every minor infringement.

Re: integer overflow

<0GxCN.312685$yEgf.279428@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: integer overflow
Newsgroups: comp.arch
References: <upq0cr$6b5m$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur1h0v$emi4$1@newsreader4.netcologne.de> <2024Feb20.091522@mips.complang.tuwien.ac.at> <SW2BN.153110$taff.74839@fx41.iad> <ur2fq1$2ic6t$1@dont-email.me> <ur2jvt$2j800$2@dont-email.me> <2024Feb20.194217@mips.complang.tuwien.ac.at> <ur4rh6$350i7$1@dont-email.me> <20240221190916.00003551@yahoo.com> <2024Feb24.123948@mips.complang.tuwien.ac.at> <GInCN.92986$Sf59.46917@fx48.iad> <2024Feb24.182125@mips.complang.tuwien.ac.at>
Lines: 25
Message-ID: <0GxCN.312685$yEgf.279428@fx09.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 25 Feb 2024 02:33:32 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 25 Feb 2024 02:33:32 GMT
X-Received-Bytes: 2093
 by: Scott Lurndal - Sun, 25 Feb 2024 02:33 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>scott@slp53.sl.home (Scott Lurndal) writes:
>>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>Michael S <already5chosen@yahoo.com> writes:
>>
>>>
>>>On ARM cores the number of physical flags registers is roughly 1/3 of
>>>the nymber of physical integer registers (46 vs. 147 on A710, 39
>>>vs. 120 on Neoverse N1/A76
>>><https://chipsandcheese.com/2023/08/11/arms-cortex-a710-winning-by-default/>,
>>>but I guess that this is due to being able to suppress flags updates
>>>rather than ignoring those that are overwritten without being read.
>>>
>>>That assumes that all of A32, T32, and A64 have the ability to
>>>suppress flags updates. Do they?
>>
>>A32, T32 and A64 have an bit in the instruction word that
>>specifies whether the flags should be updated. T16
>>only updates flags when the instruction is in an if-then (IT)
>>block.
>
>What is T16? Google does not give me anything appropriate for "ARM
>T16"? Do you mean the 16-bit-encoded instructions in T32?

The 16-bit subset of T32, yes.

Re: What integer C type to use (was: Cray style vectors)

<DOxCN.312686$yEgf.265950@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: What integer C type to use (was: Cray style vectors)
Newsgroups: comp.arch
References: <upq0cr$6b5m$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <gq4BN.90773$Sf59.78868@fx48.iad> <2024Feb20.192740@mips.complang.tuwien.ac.at> <HQ6BN.120060$STLe.3128@fx34.iad> <2024Feb20.225455@mips.complang.tuwien.ac.at> <29aBN.495740$83n7.231444@fx18.iad> <2024Feb24.232901@mips.complang.tuwien.ac.at>
Lines: 23
Message-ID: <DOxCN.312686$yEgf.265950@fx09.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 25 Feb 2024 02:42:43 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 25 Feb 2024 02:42:43 GMT
X-Received-Bytes: 1907
 by: Scott Lurndal - Sun, 25 Feb 2024 02:42 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>scott@slp53.sl.home (Scott Lurndal) writes:
>>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>scott@slp53.sl.home (Scott Lurndal) writes:
>>>>The Unix code ported relatively easily to I32LP64 because uintptr_t
>>>>had been used extensively rather than assumptions about
>>>>sizeof(int) == sizeof(int *).
>...
>>Sorry, I meant ptrdiff_t, which was used for pointer math.
>
>I have seen little code that uses ptrdiff_t; quite a bit that used
>size_t (the unsigned brother of ptrdiff_t). But my memory tells me
>that even size_t was not very widespread in 1995.

Unixware, early 90's:

$ find . -name '*.[ch]' -print | xargs grep size_t | wc -l
3435
$ find . -name '*.[ch]' -print | xargs grep ptrdiff_t | wc -l
86

memcpy was defined using size_t in the 1989 SVID Third Edition, Volume 1.

Re: integer overflow (was: Cray style vectors)

<urea8k$k0$1@gal.iecc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: integer overflow (was: Cray style vectors)
Date: Sun, 25 Feb 2024 02:56:20 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <urea8k$k0$1@gal.iecc.com>
References: <upq0cr$6b5m$1@dont-email.me> <2024Feb20.173916@mips.complang.tuwien.ac.at> <ur2vfp$31a6$1@gal.iecc.com> <2024Feb24.233358@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Feb 2024 02:56:20 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="640"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <upq0cr$6b5m$1@dont-email.me> <2024Feb20.173916@mips.complang.tuwien.ac.at> <ur2vfp$31a6$1@gal.iecc.com> <2024Feb24.233358@mips.complang.tuwien.ac.at>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sun, 25 Feb 2024 02:56 UTC

It appears that Anton Ertl <anton@mips.complang.tuwien.ac.at> said:
>John Levine <johnl@taugh.com> writes:
>>There weren't instructions to do add or subtract with
>>carry but it was pretty easy to fake by doing a branch on no carry
>>around an instruction to add or subtract 1.
>
>That is sufficient for double-word arithmetic, but not for multi-word
>arithmetic. ESA/390 adds addition-with-carry-in.

You could do it but you're right, it was a little trickier than that since
you had to check for the carry both on the addition and on the optional
second one. The add with carry instructions made it a lot simpler.

According to the IBM manuals, add with carry was added in z/Series but
you could use it in S/390 mode on a z machine, so I guess someone
really wanted it for some existing code.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Cray style vectors

<86le79uoln.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sat, 24 Feb 2024 20:58:28 -0800
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <86le79uoln.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqge2p$279ql$1@dont-email.me> <uqhiqb$2grub$1@dont-email.me> <uqlm2c$3e9bp$1@dont-email.me> <uqmn7c$3n35k$1@dont-email.me> <2024Feb16.082736@mips.complang.tuwien.ac.at> <uqnmue$3o4m9$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <86y1biy874.fsf@linuxsc.com> <02d4b67c9c2a4807b655ba503240279e@www.novabbs.org> <86h6i6xvxq.fsf@linuxsc.com> <uqsern$uurm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="d0a541e28d41d50395e069f34372e044";
logging-data="1773744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vRUh8SP004BYED5ZFQzX98QtDbA/k1gE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:HZ0boTwvApqDdzVO5BBAl8re73Y=
sha1:1qpkaKr6BIOblRUMVjw8AK3hkmE=
 by: Tim Rentsch - Sun, 25 Feb 2024 04:58 UTC

Opus <ifonly@youknew.org> writes:

> On 18/02/2024 05:01, Tim Rentsch wrote:
>
>> mitchalsup@aol.com (MitchAlsup1) writes:
>>
>>> Tim Rentsch wrote:
>>>
>>>> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>>>>
>>>>> [...]
>>>>>
>>>>> int8_t sum(int len, int8_t data[])
>>>>> {
>>>>> int s = 0;
>>>>> for (unsigned i = 0 i < len; i++) {
>>>>> s += data[i];
>>>>> }
>>>>> return (int8_t) s;
>>>>> }
>>>>
>>>> The cast in the return statement is superfluous.
>>>
>>> But the return statement is where overflow (if any) is detected.
>>
>> The cast is superfluous because a conversion to int8_t will be
>> done in any case, since the return type of the function is
>> int8_t.
>
> Of course the conversion will be done implicitly. C converts almost
> anything implicitly. Not that this is its greatest feature.
>
> The explicit cast is still useful: 1/ to express intent (it shows that
> the potential loss of data is intentional) and then 2/ to avoid
> compiler warnings (if you enable -Wconversion, which I usually
> recommend) or warning from any serious static analyzer too (which I
> highly recommend using too).

Using a cast is a poor way to express intent:

return s; // narrow accumulated value on return

is better.

Using a cast to prevent a compiler warning is an awful
convention. See also my reply to Terje's message about
Rust. Compiler writers should be ashamed for promulgating
such a moronic idea.

Re: Cray style vectors

<86h6hxuo9e.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sat, 24 Feb 2024 21:05:49 -0800
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <86h6hxuo9e.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <2024Feb16.082736@mips.complang.tuwien.ac.at> <uqnmue$3o4m9$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <86y1biy874.fsf@linuxsc.com> <02d4b67c9c2a4807b655ba503240279e@www.novabbs.org> <86h6i6xvxq.fsf@linuxsc.com> <g_pAN.85204$Sf59.5937@fx48.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="d0a541e28d41d50395e069f34372e044";
logging-data="1773744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lbpgtxPabL1XR/tHiokQU3W8RG9M7bNA="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:hhbD7GMCq73xAjblmXAaRQ2Z1/o=
sha1:9Hpm0VGb+ACsgP+ot8Gbzr3FwsQ=
 by: Tim Rentsch - Sun, 25 Feb 2024 05:05 UTC

scott@slp53.sl.home (Scott Lurndal) writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> mitchalsup@aol.com (MitchAlsup1) writes:
>>
>>> Tim Rentsch wrote:
>>>
>>>> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>>>>
>>>>> [...]
>>>>>
>>>>> int8_t sum(int len, int8_t data[])
>>>>> {
>>>>> int s = 0;
>>>>> for (unsigned i = 0 i < len; i++) {
>>>>> s += data[i];
>>>>> }
>>>>> return (int8_t) s;
>>>>> }
>>>>
>>>> The cast in the return statement is superfluous.
>>>
>>> But the return statement is where overflow (if any) is detected.
>>
>> The cast is superfluous because a conversion to int8_t will be
>> done in any case, since the return type of the function is
>> int8_t.
>
> I suspect most experienced C programs know that.

I expect most C programmers, even most experienced C programmers,
do not know the rules for conversions of return values. How many
readers here in comp.arch do you think know those rules? How
confident are you that you can state them, without having to look
them up? I know I was surprised when I first discovered that
return statements do not convert values the way I expected.

> Yet, the 'superfluous' cast is also documentation that the
> programmer _intended_ that the return value would be narrowed.

Using a cast is a poor way to express such an intent, as I have
explained in other postings.

Re: What integer C type to use

<86a5npunub.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: What integer C type to use
Date: Sat, 24 Feb 2024 21:14:52 -0800
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86a5npunub.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <2024Feb20.184737@mips.complang.tuwien.ac.at> <cc04a47d7852ec7370386cc579a66e36@www.novabbs.org> <ur4t1g$35evo$1@dont-email.me> <86a5npwyxo.fsf@linuxsc.com> <452f33678746bc9bfa7296ca1fe77a18@www.novabbs.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="d0a541e28d41d50395e069f34372e044";
logging-data="1773744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mYZCzQK7wm6hFvGaNhlWgdh/ZI06BoBg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:kmkM2D7UdxPDsM5gci/yL11TA2I=
sha1:KrTOqt2MWgOHFkhQ5RzwMv4Ah2w=
 by: Tim Rentsch - Sun, 25 Feb 2024 05:14 UTC

mitchalsup@aol.com (MitchAlsup1) writes:

> Tim Rentsch wrote:
>
>> 10-4.
>>
>> It always surprises me to encounter people who think signed types
>> should be the default, with almost no exceptions. It's one thing
>> to be somewhat cavalier about shooting yourself in the foot, it's
>> quite another to deliberately choose a large caliber weapon ahead
>> of time.
>
> I am of the opinion that the proper default type is unsigned--the
> only reason to use a singed type is if at some point in it life it
> needs to hold a negative number.

I expect you mean that the proper default choice for signedness
is unsigned -- unsigned int rather than int, unsigned long rather
than long, etc. I agree with that view. Whether unsigned int is
a better default than unsigned long, or vice versa, is another
discussion.

> With C-promotions, unsigned is safer when mixing signed and unsigned.

Here too I expect you mean when the respective types have the
same width. Mixing a signed long and an unsigned int, for
example, is a red flag in my book.

Re: What integer C type to use (was: Cray style vectors)

<865xydunqe.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: What integer C type to use (was: Cray style vectors)
Date: Sat, 24 Feb 2024 21:17:13 -0800
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <865xydunqe.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur0ka6$23ma8$1@dont-email.me> <dd9c82c9be34460dc6fea35c8608e51d@www.novabbs.org> <2024Feb20.083240@mips.complang.tuwien.ac.at> <2024Feb20.130029@mips.complang.tuwien.ac.at> <ur2jpf$2j800$1@dont-email.me> <gq4BN.90773$Sf59.78868@fx48.iad> <2024Feb20.192740@mips.complang.tuwien.ac.at> <HQ6BN.120060$STLe.3128@fx34.iad> <2024Feb20.225455@mips.complang.tuwien.ac.at> <29aBN.495740$83n7.231444@fx18.iad> <2024Feb24.232901@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="d0a541e28d41d50395e069f34372e044";
logging-data="1773744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VeC9V8LB5lKohq3ujqPKZFOOh/PtPKrk="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:fuImjyoYsqkTwyW3n3oQCMW04GI=
sha1:ZN12RY5EvLBzrDiAS7E15s2699g=
 by: Tim Rentsch - Sun, 25 Feb 2024 05:17 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:

> scott@slp53.sl.home (Scott Lurndal) writes:
>
>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>
>>> scott@slp53.sl.home (Scott Lurndal) writes:
>>>
>>>> The Unix code ported relatively easily to I32LP64 because uintptr_t
>>>> had been used extensively rather than assumptions about
>>>> sizeof(int) == sizeof(int *).
>
> ...
>
>> Sorry, I meant ptrdiff_t, which was used for pointer math.
>
> I have seen little code that uses ptrdiff_t; quite a bit that used
> size_t (the unsigned brother of ptrdiff_t). But my memory tells me
> that even size_t was not very widespread in 1995.

In 1995 a problem with both size_t and ptrdiff_t is that there
were no corresponding length modifiers for those types in
printf() format conversions (corrected in C99).

Re: Cray style vectors

<861q91ulhs.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sat, 24 Feb 2024 22:05:35 -0800
Organization: A noiseless patient Spider
Lines: 79
Message-ID: <861q91ulhs.fsf@linuxsc.com>
References: <upq0cr$6b5m$1@dont-email.me> <uqge2p$279ql$1@dont-email.me> <uqhiqb$2grub$1@dont-email.me> <uqlm2c$3e9bp$1@dont-email.me> <uqmn7c$3n35k$1@dont-email.me> <2024Feb16.082736@mips.complang.tuwien.ac.at> <uqnmue$3o4m9$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur1h0v$emi4$1@newsreader4.netcologne.de> <86r0h6wyil.fsf@linuxsc.com> <ur7v2r$ipnu$1@newsreader4.netcologne.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="d0a541e28d41d50395e069f34372e044";
logging-data="1797670"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oEva1B/UZOkd9xfN4QQyxsqXqw6Y7iFQ="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:mFM19nz3QTkdEqfL0B1HGgX6XaA=
sha1:+zmasoDf2sJ3CHcj7DFZPdOevG4=
 by: Tim Rentsch - Sun, 25 Feb 2024 06:05 UTC

Thomas Koenig <tkoenig@netcologne.de> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> schrieb:
>
>> Thomas Koenig <tkoenig@netcologne.de> writes:
>>
>>> Signed integer overflow is undefined behavior in C and prohibited
>>> in Fortran. Yet, there is no straightforward, standard-compliant
>>> way to check for signed overflow (and handle this appropriately)
>>> in either language. [...]
>>
>> It isn't hard to write standard C code to determine whether a
>> proposed addition or subtraction would overflow, and does so
>> safely and reliably.
>
> Also efficiently and without resorting to implementation-
> defined or undefined behavior (and without needing a bigger
> type)?

Heavens to Betsy! Are you impugning the quality and excellence
of my code? Of *my* code? I can only hope that you are suitably
chagrined and contrite. ;)

>> It's a little bit tedious perhaps but not
>> difficult. Checking code can be wrapped in an inline function
>> and invoke whatever handling is desired, within reason.
>
> Maybe you could share such code?

Rather that do that I will explain.

An addition overflows if the two operands have the same sign and
the sign of an operand is the opposite of the sign of the sum
(taken mod the width of the operands). Convert the signed
operands to their unsigned counterparts, and form the sum of the
unsigned values. The sign is just the high-order bit in each
case. Thus the overflow condition can be detected with a few
bitwise xors and ands.

Subtraction is similar except now overflow can occur only when
the operands have different signs and the sign of the sum is
the opposite of the sign of the first operand.

The above description works for two's complement hardware where
unsigned types have the same width as their corresponding signed
types. I think for most people that's all they need. The three
other possibilities are all doable with minor adjustments, and
code appropriate to each particular implementation can be
selected using C preprocessor conditional, as for example

#if UINT_MAX > INT_MAX && INT_MIN == -INT_MAX - 1
// this case is the one outlined above

#elif UINT_MAX > INT_MAX && INT_MIN == -INT_MAX

#elif UINT_MAX == INT_MAX && INT_MIN == -INT_MAX - 1

#elif UINT_MAX == INT_MAX && INT_MIN == -INT_MAX

Does that all make sense?

> The next question would be how to do the same for multiplication....

Multiplication is a whole other ball game. First we need to
consider only the widest types, because narrower types can be
carried out in a wider type and the resulting product value
checked. Off the top of my head, for the widest types I would
try converting to float or double, do a floating-point multiply,
and do some trivial accepts and trivial rejects based on the
exponent of the result. Any remaining cases would need more
care, but probably (we hope!) there aren't many of those and they
don't happen very often. So for what it's worth there is my
first idea. Second idea is to compute a double-width product,
or at least part of one, using standard multiple-precision
arithmetic, and speed compare against the floating-point method.
I better stop now or the ideas will probably get worse rather
than better. :/

Re: Cray style vectors

<2024Feb25.090312@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Cray style vectors
Date: Sun, 25 Feb 2024 08:03:12 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 48
Message-ID: <2024Feb25.090312@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <2024Feb16.152320@mips.complang.tuwien.ac.at> <uqobhv$3o4m9$2@dont-email.me> <1067c5b46cebaa18a0fc50fc423aa86a@www.novabbs.com> <uqpngc$3o4m9$3@dont-email.me> <uqpuid$bhg0$1@dont-email.me> <2024Feb17.190353@mips.complang.tuwien.ac.at> <uqqvkc$i2cu$1@dont-email.me> <uqvk2o$1snbf$1@dont-email.me> <ur1h0v$emi4$1@newsreader4.netcologne.de> <86r0h6wyil.fsf@linuxsc.com> <ur7v2r$ipnu$1@newsreader4.netcologne.de> <861q91ulhs.fsf@linuxsc.com>
Injection-Info: dont-email.me; posting-host="acc5acb15cbb9708351b53f2961c1b40";
logging-data="1852196"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yDSM3ZSlZyxmajgpto2N7"
Cancel-Lock: sha1:CU3QvMs/Tw/ZAMtuiGJ4Vh8NiBM=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sun, 25 Feb 2024 08:03 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>Second idea is to compute a double-width product,
>or at least part of one, using standard multiple-precision
>arithmetic, and speed compare against the floating-point method.

What "standard multiple-precision arithmetic" is there in C? I am not
aware of any.

If you have widening multiplication in the language, things are
trivial. I'll use Forth because it has widening multiplication:

For the unsigned case:

( u1 u2 ) um* if ... ( handle the overflow case ) ... then

For the signed case:

( n1 n2 ) m* >r s>d r> <> if ... ( handle the overflow case ) ... then

S>D ( n -- d ) sign-extends a single-cell to a double-cell.

For those of you who are Forth-illiterate, here's how it might look in
C, with (U)Word and (U)Doubleword integer types and some assumptions
about things that the standardized subset of C does not define:

For the unsigned case:

UDoubleword ud = u1 * (UDoubleword)u2;
if ((ud>>(8*sizeof(UWord))) != 0) {
... /* handle the overflow case */ ...
}

For the signed case:

Doubleword d = n1 * (Doubleword)n2;
Word dlo = d; /* dlo contains the low-order bits of d */
if (d != (Doubleword)dlo) {
.... /* handle the overflow case */ ...
}

I'll leave it to the advocates of the standardized subset of C to
rewrite this in a way that can be executed in a strictly conforming
program.

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

Re: integer overflow (was: Cray style vectors)

<2024Feb25.094032@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: integer overflow (was: Cray style vectors)
Date: Sun, 25 Feb 2024 08:40:32 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 18
Message-ID: <2024Feb25.094032@mips.complang.tuwien.ac.at>
References: <upq0cr$6b5m$1@dont-email.me> <2024Feb20.173916@mips.complang.tuwien.ac.at> <ur2vfp$31a6$1@gal.iecc.com> <2024Feb24.233358@mips.complang.tuwien.ac.at> <urea8k$k0$1@gal.iecc.com>
Injection-Info: dont-email.me; posting-host="acc5acb15cbb9708351b53f2961c1b40";
logging-data="1858192"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cRNHtLR3As09uo4dlc2Bu"
Cancel-Lock: sha1:qZZsnBaHh06Rpjn428dfPsGz4Bw=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sun, 25 Feb 2024 08:40 UTC

John Levine <johnl@taugh.com> writes:
>According to the IBM manuals, add with carry was added in z/Series but
>you could use it in S/390 mode on a z machine, so I guess someone
>really wanted it for some existing code.

Interestingly,
<https://en.wikibooks.org/wiki/360_Assembly/360_Instructions> lists
ALC, ALCR, SLB and SLBR as belonging to the 390 instructions, and only
ALCG, ALCGR, SLBG and SLBGR (the 64-bit variants) as Z instructions.

If they added ALC, ALCR, SLB and SLBR only in Z (but in the S/390
mode), that is counterevidence for the claim that add-with-carry is
less important for 64-bit systems than for 32-bit systems.

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


devel / comp.arch / Re: Cray style vectors

Pages:12345678910
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor