Techniques for execution-driven loop splitting and load-safe code hosting
are provided. Compiled code includes statements associated with an
original loop and statements associated with an alternative loop. The
alternative loop reproduces the original loop except for conditional
load-safe invariant expressions that appeared in the original loop and
that are separated out of the alternative loop. During processing, once
the conditional load-safe invariant expressions are computed and
referenced for a first time within the original loop, processing
dynamically switches to the alternative loop where the conditional
load-safe invariant expressions are computed outside of the alternative
loop and referenced from within the alternative loop.