limit checks

Stephen Weeks MLton@sourcelight.com
Sat, 26 Jan 2002 12:57:37 -0800


> which seems to suggest that we're getting _more_ limit-checks when
> using the coalescing

That is quite possible, since limit checks are moved backward across
control flow edges (forward in time :-).  For example, if there is an
if-test that requires a limit check only on one branch, then the limit
check will be moved up before the test with coalescing.

We were very much focused on decreasing the static number of limit
checks.  We are not at the min, as your pathalogical example showed,
but we're probably pretty close.  There are clearly improvements that
could be had to our current approach that will decrease the dynamic
counts without increasing the static counts.  For example, pushing a
limit check down an if branch if it is only needed on one branch.

What's not clear is if working on decreasing the dynamic counts is
worth the effort.  It's tough to measure the run-time cost of limit
checks, which I would guess is almost zero.  But maybe we need to make
an attempt.  Also, the interplay with other optimizations, like
register allocation, argues that keeping the static count small is
good because fewer variables will be live across limit checks, and
will hence be free to live in pseudo-regs.