Paolomio wrote:Folknology wrote:What happens if you move the pragma to the line above the For loop but below the while, does that make any difference?
The pragma is function-wide, and must appear above the affected function.
No luck there...
Says who?
Tools User Guide 11.2 wrote:
#pragma loop unroll (n) (XC only)
This pragma controls the number of times the next do, while or for loop in the
current function is unrolled. n specifies the number of iterations to unroll, and
unrolling is performed only at optimization level 01 and higher. Omitting the
(n ) parameter causes the compiler to try and fully unroll the loop. Outside of a
function the pragma is ignored. The compiler produces a warning if unable to
perform the unrolling.
Code: Select all
void test(streaming chanend c)
{
int j, x;
while(1)
{
#pragma loop unroll
for(j = 5; j >= 1; j--)
{
x = j+1;
c <: x;
}
}
}
works fine here.
I added a chanend to avoid the while loop being optimized to nothing because nothing useful is done with x.
Code: Select all
test:
.L26:
.L12:
.L16:
.L17:
ldc r1, 0x6
.L64:
out res[r0], r1
.L19:
ldc r1, 0x5
.L65:
out res[r0], r1
ldc r1, 0x4
.L66:
out res[r0], r1
mkmsk r1, 0x2
.L67:
out res[r0], r1
ldc r1, 0x2
.L68:
out res[r0], r1
bu .L12