Low overhead looping support

Michael Hayes m.hayes@elec.canterbury.ac.nz
Sun Feb 28 18:15:00 GMT 1999


Jeffrey A Law writes:
 > I guess that makes sense.  Presumably we add the insn before the jump to the
 > loop test for loops where we have not removed that jump.    Right Michael?

I'm not sure if I understand what you mean here?

What we do is replace the conditional jump at the end of the loop with
the new decrement and branch jump insn.

I've written up the entries in md.texi for the
decrement_and_branch_until_zero and decrement_and_branch_on_count
insns.  However, I'm unhappy with the operation of the latter and have
come up with another more general scheme.

For starters d_a_b_o_c is too much of a mouthful and is easy to
confuse with d_a_b_u_z and so I propose that we have a pair of insns
doloop_begin and doloop_end to replace init_branch_on_count and
d_a_b_o_c.

doloop_begin would have two operands; operand 0 being a const_int
specifying the number of iterations if this can be computed at
compile-time or a reg to hold the computed number of iterations at
run-time; operand 1 being a const_int specifying the number of
enclosed loops.

If the number of iterations or enclosed loops cannot be dealt with,
this pattern would FAIL.  Otherwise, a pseudo register would be
allocated as the loop counter and initialised with the loop iterations
operand.  This register rtx would be stored in a static variable.  (I
envisage that this pattern would also decrement the iteration count by
one if the looping instruction employed a GE test.)

The doloop_begin pattern would have a matching doloop_end pattern.
If the doloop_begin did not FAIL, a label marking the top of the loop
would be emitted and passed as an operand to the doloop_end pattern

There is an argument for the doloop_begin pattern to generate and emit
this label itself and for it to pass the label to the doloop_end
pattern through a static variable.  This is to cater for targets that
emit the looping instruction at the top of the loop and which need to
load the address of the top label into a special register (currently I
do this with a machdep kludge).

Any comments?

Michael.









More information about the Gcc-patches mailing list