A method of constructing and unrolling speculatively counted loops. The
method of the present invention first locates a memory load instruction
within the loop body of a loop. An advance load instruction is inserted
into the preheader of the loop. The memory load instruction is replaced
with a check instruction. The loop body is unrolled. A cleanup block is
generated for said loop.