🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #854

Re: vector length CSR?

#854
From: David Brown
Date: Sat, 21 Nov 2026 11:50
48 lines
3551 bytes
On 20/11/2026 19:57, Thomas Koenig wrote:
> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:
>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote:
>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote:
>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>>>>>      s = 0;
>>>>>>      for (long int i=0; i<n; i++)
>>>>>>        s = s + a[i];
>> ...
>>> So does that mean that no parallelization of the above loop is legal?
>>> Even if if wouldn't make any difference, e.g. the array entries are
>>> unsigned integers?
>>
>> For unsigned integers and signed integers in C, this loop can be
>> reassociated just fine.
> 
> Not according to the C standard.

Yes, according to the C standards.  UB on signed integer overflow means 
the language does not say anything about what happens on overflow - it 
does not mean the compiler has to handle it specially.

> 
>>
>> For unsigned integers: The associative law holds for modulo
>> arithmetic, in particular unsigned addition and multiplication in C.
>>
>> For signed integers: The compiler can choose what it wants to do in
>> case of overflow; e.g., it can choose modulo arithmetic, which is
>> associative.
> 
> Or it can issue an overvlow trap, for example with -fsanitize=undefined.
> 

The C standard does not require overflow traps in any way.  It 
explicitly says /nothing/ about what happens on signed integer 
arithmetic overflow.  So there is no problem doing a summation loop like 
this in any order, serially or in parallel, with signed integer types or 
unsigned integer types.

A particular compiler implementation, possibly under control of 
particular flags, can of course give specific behaviour to signed 
integer overflow.  And in that case the compiler must generate code that 
fits the semantics it is giving.

Technical Details
Message-ID: <11ds0io$12f8$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11cpqih$acf5$1@dont-email.me> <sgu0flpndaqltpdbft40fghmi7vk78q2hs@4ax.com> <11cq2v7$dh5b$1@dont-email.me> <8jk1fl182pskj3fsmp4ju6qf420pgl0htg@4ax.com> <11csull$1ef6e$1@dont-email.me> <2026Nov9.230104@mips.complang.tuwien.ac.at> <11cvcr4$28k7g$1@dont-email.me> <11d3npt$3mmho$1@dont-email.me> <11dn936$2ebc2$1@dont-email.me> <11dndfd$2fr9j$1@dont-email.me> <11dngb5$2he51$1@dont-email.me> <2026Nov19.203832@mips.complang.tuwien.ac.at> <11dq56a$3f094$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.arch
Subject: Re: vector length CSR?
Date: Sat, 21 Nov 2026 12:50:48 +0100
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <11ds0io$12f8$1@dont-email.me>
References: <11cpqih$acf5$1@dont-email.me>
 <sgu0flpndaqltpdbft40fghmi7vk78q2hs@4ax.com> <11cq2v7$dh5b$1@dont-email.me>
 <8jk1fl182pskj3fsmp4ju6qf420pgl0htg@4ax.com> <11csull$1ef6e$1@dont-email.me>
 <2026Nov9.230104@mips.complang.tuwien.ac.at> <11cvcr4$28k7g$1@dont-email.me>
 <11d3npt$3mmho$1@dont-email.me> <11dn936$2ebc2$1@dont-email.me>
 <11dndfd$2fr9j$1@dont-email.me> <11dngb5$2he51$1@dont-email.me>
 <2026Nov19.203832@mips.complang.tuwien.ac.at> <11dq56a$3f094$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 21 Nov 2026 11:50:49 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="35304"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19Y5MThbR82TrKSznVsaWaiWLrsPSQziAQ="; posting-host="e9cc8568760c122c84a8bb7d362e291d"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7JvF8NCL4sJXSMrBUUfTezlrn+g= sha256:rPTJK8UsHJDd+ZYZOQqCxWtLVj86j7Li2eyVcdvSYSA=
	sha1:XQssGDaSeax7qH3c2F3o6uO/t3I= sha256:/cE9f0724m9p6PwGO9o0lXr8DCEYNPLwfaystI4h4PY=
Content-Language: en-GB
In-Reply-To: <11dq56a$3f094$1@dont-email.me>