Array bound checks removal increasing importance

Meta via Digitalmars-d digitalmars-d at puremagic.com
Sat May 31 18:47:29 PDT 2014


On Saturday, 31 May 2014 at 23:30:41 UTC, Walter Bright wrote:
> There isn't a suitable place. To make it work, data flow 
> analysis would have to be added to the front end. While doable, 
> this is not a simple addition. Eventually, we'll have to do it 
> as a lot of things become possible & better with data flow 
> analysis, not just bounds check elimination.

I've always wondered if VRP can be leveraged in certain 
situations. I can't remember exactly how it's supposed to work, 
but very basically, isn't it just numeric variables (and 
expressions?) having an associated range that they carry around 
with them at compile time, so something like this is possible:

long n1 = long.max;
int n2 = n1 % 3; //No cast needed due to VRP

Couldn't this be used for other things as well, such as detecting 
numeric overflow at compile time, or like Nordlow suggested, 
figuring out when it's safe to elide an array bounds check?


More information about the Digitalmars-d mailing list