version=D_16

Luís Marques via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 10 16:01:50 PDT 2017


On Monday, 10 July 2017 at 22:39:22 UTC, Petar Kirov [ZombineDev] 
wrote:
> The problem Walter pointed to is that due to integer promotion, 
> arithmetic operands of types smaller than int are converted to 
> int, hence even if you use bytes and shorts you would end up 
> using ints, which are expensive on CPUs with no native 32-bit 
> registers. In theory, you could write your code so that it's 
> easy for the optimizer to prove that you're only using 8 or 16 
> bits and variables would fit in single registers, so you would 
> be able to get away without a performance penalty for using a 
> language where ints are 32-bit.

Ah, that makes sense. Thanks for clarifying. For me it hasn't 
proved a problem, but I could see it being if you do a lot of 
arithmetic with 16-bit integers.


More information about the Digitalmars-d mailing list