In the gcc 4.4.6
docs it is stated:
-funroll-all-loops: Unroll all loops, even if their number of iterations is uncertain when the loop isentered.
I am compiling this code:
int unroll(){
int i = 0;
int array[1000];
do {
use(i,array);
i++;
}while(i<1000);
return(0);
}
void use(int i, int *array){
int x = i*5;
array[i] = x;
}
...once with the funroll-all-loops
optimizations, once without:
OPT = -funroll-all-loops
NOOPT = -O0
Then I use diff
to compare the assembly code of each (produced using -S -fverbose-asm
).
The produced code is identical.
Tried changing the loop to a do while
;
adjusting the loop counter (up to 100);
changing the statements within the loop body.
What could I be missing? Why is this loop not being unrolled?
Update
Nikos C suggested to raise the loop enroll parameter using --param max-unroll-times=N
where N is the upper limit.
While that was a sensible suggestion, it did not change behaviour.
I also lowered the loop iterations to only 10.
Also updated the code to actually 'do' something, no change.