Gopal V wrote:

I'm assuming that the temporaries are the things being moved around here ?.


It is not so much a matter of moving things around, but a matter of allocating (and renumbering) parrot (or for JIT) processor registers. These are of course mainly temporaries, but even when you have some find_lexical/do_something/store_lexical, imcc selects the best register for all involved ops, temps or "variables" it doesn't really matter.


The only question I have here , how does imcc identify loops ?. I've
been using "if goto" to loop around , which is exactly the way assembly
does it. But that sounds like a lot of work identifying the loops and
optimising accordingly.


Here are basic blocks, the CFG and loop info of
0         set I0, 10
1 x:
1         unless I0, y
2         dec I0
2         print I0
2         print "\n"
2         branch x
3 y:
3        end

Dumping the CFG:
-------------------------------
0 (0)    -> 1            <-
1 (1)    -> 2 3                  <- 2 0
2 (1)    -> 1            <- 1
3 (0)    ->              <- 1

Loop info
---------
loop 0,  depth 1, size 2, entry 0, contains blocks:
1 2


To make it more clear -- identifying tight loops and the usage weights
correctly. 10 uses of $I0 outside the loop vs 1 use of $I1 inside a 100
times loop. Which will be come first ?.


This is basically the current score calculation used for register allocation:

r->score = r->use_count + (r->lhs_use_count << 2);

r->score += 1 << (loop_depth * 3);


Gopal

leo





Reply via email to