When I compiled my application, the performance was worse than I expected and I figured out the compiler was reporting a warning like the below.
remark #25461: Imperfect Loop Unroll-Jammed by 2 (pre-vector)
And this is my short code.
for(i=0; i<num; i++){
values[i] = func(a, b, c);
}
The index variable, num is alwasy 1024. Why is the loop unroll-jammmed imperfectly? Also, When I modify the code like the below, unroll-jamming doesn't occur! What is the condition of occuring unroll-jamming?
for(i=0; i<num; i++){
value += func(a, b, c);
}
Actually, the code is a part of large file, so I can't write the entire code here. But the below is the code including func().
int values[num];
int func(int a, int b, int c)
{
int i=0;
int total=0;
for(i=0; i<num; i++){
total = a*b+c;
}
return total;
}
int main(void){
int i=0;
int min=0;
for(i=0; i<num; i++){
values[i] = func(a, b, c);
}
for(i=0; i<num; i++){
value = values[i];
}
printf("value: %d\n", value);
return 0;
}