Deutsch   English   Français   Italiano  
<vcbhn2$3ecji$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.arch
Subject: Re: Computer architects leaving Intel...
Date: Tue, 17 Sep 2024 11:21:38 +0200
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <vcbhn2$3ecji$1@dont-email.me>
References: <2024Aug30.161204@mips.complang.tuwien.ac.at>
 <vbcob9$dvp4$1@dont-email.me> <vbd6ia$e0ld$2@dont-email.me>
 <UxpCO.174965$Hld5.7714@fx15.iad> <vc41rl$1fhjd$1@dont-email.me>
 <2024Sep14.152652@mips.complang.tuwien.ac.at>
 <d93c1dc0455692767c89ea9f7bd47ed1@www.novabbs.org>
 <vc4o0l$1kuqf$1@dont-email.me> <vc6vno$285g2$1@dont-email.me>
 <vc8qor$2od9v$1@dont-email.me> <vc99fi$2re3k$2@dont-email.me>
 <vcb6bg$3c9qf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 17 Sep 2024 11:21:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3e52a47a8c62d553adb0a23714e2b020";
	logging-data="3617394"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/m80buDUbpi/pSfWBiuLf/YIFWVksSKb4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:aNuYA3bb/5odNhlumXXQEtl+tjk=
Content-Language: en-GB
In-Reply-To: <vcb6bg$3c9qf$1@dont-email.me>
Bytes: 2989

On 17/09/2024 08:07, Terje Mathisen wrote:
> David Brown wrote:
>> On 16/09/2024 10:37, Terje Mathisen wrote:
>>> This becomes much simpler in Rust where usize is the only legal index 
>>> type:
>>>
>>> Yeah, you have to actually write it as
>>>
>>>  Â  y = p[x];
>>>  Â  x += 1;
>>>
>>> instead of a single line, but this makes zero difference to the 
>>> compiler, right?
>>>
>>
>> I don't care much about the compiler - but I don't think this is an 
>> improvement for the programmer.  (In general, I dislike trying to do 
>> too much in a single expression or statement, but some C constructs 
>> are common enough that I am happy with them.  It would be hard to 
>> formulate concrete rules here.)
>>
>> And the resulting object code is less efficient than you get with 
>> signed int and "y = p[x++];" (or "y = p[x]; x++;") in C.
> 
> Is that true? I'll have to check godbolt myself if that is really the case!
> 

It is not true - or at least, it shouldn't be true.  I had thought the 
Rust code was using the equivalent of a C "unsigned int" here, which 
would require extra code for wrapping semantics.  But that was just my 
misunderstanding of Rust and its types - with a 64-bit unsigned type, it 
should give the same results as C.  However, there's no harm in checking 
it and letting us know.

(I've previously shown how "y = p[x++];" in C is less efficient on 
x86-64 if x is "unsigned int", compared to "int" or 64-bit types for x.)