On Thu, Apr 14, 2011 at 3:01 PM, Antonio Cuni <anto.c...@gmail.com> wrote:
>
> Of course the ovf check needs to be there because we don't specialize the loop
> on the value of n. Although it might be cool to be able to do promotion at
> applevel, for those who really want :-)

Well, you can actually (sort of):

    def main(n):
        i, a = 0, 0
        exec """def promote(n):
                    assert n==%d""" % n
        while i < n:
            promote(n)
            a += i+5
            i += 1
        return a

With this I get two extra operations in the loop:

    i11 = ptr_eq(ConstPtr(ptr10), p7)
    guard_false(i11, descr=<Guard4>) [p1, p0, p2, p3, p4, i5, i6]

but p7 is loop-invariant so they should be easy to get rid of. I don't
know why they are not already...

-- 
Håkan Ardö
_______________________________________________
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev

Reply via email to