The other part of the work is the algorithm that finds loop variants. It is similar to the algorithm for variable colour inference, so you do have a starting point.
On 28/08/2010 11:12 PM, "Hakan Ardo" <hakan@debian.org> wrote:
Hi,
some time ago, there were some discussion about loop invaraints, but
no conclusion. What do you think about the following approach:
- Let optimize_loop mark the arguments in loop.inputargs as invariant
if they appear at the same position in the jump instruction at the end
before calling propagate_formward
- Let the optimize_... methods emit operations that only uses
invariant arguments to some preamble instead of emitting them to
self.newoperations whenever that is safe. Also, the result of these
operations should probably be marked as invariant.
- Insert the created preamble at every point where the loop is called,
right before the jump.
- When compiling a bridge from a failing guard, run the the preamble
through propagate_formward and discard the emitted operations, to
inherit that part of the state of Optimizer.
This should place the invariant instructions at the end of the entry
bridge, which is a suitable place, right? At the end of a bridge from
a failing guard that maintains the invariants the optimizer should
remove the inserted preamble again, right? And at the end of a bridge
that invalidates them, enough of the preamble will be kept to maintain
correct behavior, right?
--
Håkan Ardö
_______________________________________________
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev