-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
When using loop unrolling, we currrently assume that the number of iterations is a multiple of the unrolling factor.
SLOTHY should support the combination of unrolling and an unknown iteration count. The pattern to be produced should look like this:
if loop_cnt < UNROLL:
jump TAIL
loop:
BODY
sub loop_cnt, loop_cnt, UNROLL
cmp loop_cnt, UNROLL
branch_if_greater_equal
TAIL:
cmp loop_cnt #1
jump TAIL_1
cmp loop_cnt #2
jump TAIL_2
...
When SW pipelining is used, this also needs to take into account the number of exceptional iterations, e.g. for a loop with early but no late instructions:
cmp loop_cnt, UNROLL:
branch_if_smaller TAIL
... PREAMBLE FOR UNROLLED LOOP ...
sub loop_cnt, loop_cnt, UNROLL
cmp loop_cnt, UNROLL
branch_if_smaller POSTAMBLE
LOOP:
BODY
sub loop_cnt, loop_cnt, UNROLL
cmp loop_cnt, UNROLL
branch_if_greater_equal LOOP
POSTAMBLE:
... POSTAMBLE FOR UNROLLED LOOP...
TAIL:
cmp loop_cnt #1
jump TAIL_1
cmp loop_cnt #2
jump TAIL_2
...
pennyannn
Metadata
Metadata
Assignees
Labels
No labels