SPRUI04F july 2015 – april 2023
advice #30003: Loop at line 8 cannot be scheduled efficiently, as it
contains complex conditional expression. Try to simplify
condition.
Your code contains a complex conditional expression, possibly a large "if" clause, within a loop, which is preventing optimization. The compiler will optimize small “if” statements (“if” statements with “if” and “else” blocks that are short or empty). The compiler will not optimize large "if" statements, and such large if statements within the loop body will disqualify the loop for software pipelining. Software-pipelining is a key optimization; you may see reduced performance without it.
In the examples below, Example 1 will pipeline, but Example 2 won't :
Example 1:
for (i=0; i < N; i++)
{
if (!flag) {
//statements
}
else {
x[i] = y[i];
}
}
Example 2:
for (i = 0; i < n; i++)
{
if (!flag) {
//statements
}
else {
if (flag == 1) x[i] = y[i];
}
}
Example 1 will have significantly better performance than Example 2 because it pipelines successfully. But Example 2 can be pipelined if the code is modified to eliminate the nested "if" :
for (i = 0; i < n; i++)
{
if (!flag) {
//statements
}
else {
p = (flag == 1);
x[i] = !p * x[i] + p * y[i] ;
}
}