checkedint call removal

via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 28 02:32:16 PDT 2014


On Monday, 28 July 2014 at 08:42:16 UTC, bearophile wrote:
>
> The same kind of optimization is desired for a SInt or other 
> library-defined types. So the point of this discussion is how 
> to do this. The problem is that the compiler has some static 
> information about ranges, but to optimize away user-defined 
> types such information needs to be read and given to "static 
> ifs" to replace the calls to muls() to calls to regular 
> operations.

Not sure if this is the right way to do carry/overflow 
optimization, but I can see the value of having range information 
when doing CTFE for building minimal lookup tables/perfect 
hashing etc.

IMO muls should yield 2N bits of output for N bits input, then 
the compiler should do strength reduction.

Adds should be done on N+1 bits types, using 33 bit output for 32 
bits input, then strength reduce it to >=32 bit output if both 
operands are 31 bits or less?


More information about the Digitalmars-d mailing list