A Simple Analysis to Eliminate Overflow Checking on Increments
Stephen Weeks
MLton@sourcelight.com
Fri, 13 Jul 2001 15:47:15 -0700
> It really is a shame about not getting `='. I always make my loops terminate
> on equality. One of the reasons is that I WANT going off by one to die as
> quickly as possible, not seem to be ok.
I don't understand. If you use '=' and start in the wrong place, then your loop
will run 'til overflow. If you use >= or <=, then your loop will stop
immediately.
> I remember thinking at the time that
> this would make automatic detection harder.
Yeah. Equals is harder, but not quite as hard as bounds checking, I think. All
I need to do is a little range analysis.
> In your mail it looks like you say
> ? < minInt
> when you meant
> ? < maxInt
Oops. You're right.
> Is this analysis sound in the presence of handle statements?
I don't see why not. We understand the intraprocedural control-flow of
raise/handle as well as anything else, and there is nothing interprocedural to
this analysis.
> I tried to think how tough it would be to tweak such an analysis into one
> that knew subscript's weren't out of range. The hard thing is that you need
> to tie conditions on the index to the array being subscripted.
Yeah, bounds checking is much harder. I'm still thinking about how to even get
simple for loops.