Transforms loops by creating multiples copies of the loop body.
A loop is executed for the number of iterations specified by the loop induction variable. The number of iterations can also be impacted by logic inside the loop body (for example, break or modifications to any loop exit variable). The loop is implemented in the RTL by a block of logic representing the loop body, which is executed for the same number of iterations.
syn.directive.unroll command allows the loop
to be fully or partially unrolled. Fully unrolling the loop creates as many copies
of the loop body in the RTL as there are loop iterations. Partially unrolling a loop
by a factor N, creates N copies of the loop body and adjusting the loop
If the factor N used for partial unrolling is not an integer multiple of the original loop iteration count, the original exit condition must be checked after each unrolled fragment of the loop body.
To unroll a loop completely, the loop bounds must be known at compile time. This is not required for partial unrolling.
<location>is the location of the loop (in the
format function[/label]) to be unrolled.
- Specifies a non-zero integer indicating that partial unrolling is
The loop body is repeated this number of times. The iteration information is adjusted accordingly.
- Effective only if a factor is specified (partial unrolling).
- Fixed bounds
No exit condition check is performed if the iteration count is a multiple of the factor.If the iteration count is not an integer multiple of the factor, the tool:
- Prevents unrolling.
- Issues a warning that the exit check must be performed to proceed.
- Variable bounds
The exit condition check is removed. You must ensure that:
- The variable bounds is an integer multiple of the factor.
- No exit check is in fact required.
- Fixed bounds
- Disable unroll for the specified loop.
L1 in function
foo. Place the pragma in the body of loop
Specifies an unroll factor of 4 on loop
L2 of function
the exit check. Place the pragma in the body of loop
syn.directive.unroll=skip_exit_check factor=4 foo/L2