On Wed, Nov 07, 2001 at 10:15:07AM -0500, Ken Fox wrote: > I've been thinking of ways to speed up stuff like: > foreach my $x (@vector) { > $x *= $scale > } > > If Perl can keep the loop index in an integer register, then Parrot > could use fast loop ops. IMHO there's no point in using fast loop ops > if taking the length of @vector is expensive. Huha? I don't see what the problem is with keeping the index in an I register. The problem is with keeping the _current element_ in an I register.
# @vector is P0 # $scale is P1 # $x will be P2 # get_elem p, p, i|s|ic|sc is obvious # get_len i, p is obvious # mul is extended to work on P operands. set I0, 0 loop: get_elem P2, P0, I0 mul P2, P2, P1 inc I0 get_length I1, P0 lt I0, I1, loop # end of loop