advice #30006: Loop at line 22 cannot be scheduled efficiently, as it contains a function call ("function_name"). Try making "function_name" an inline function.
There is a function call within a loop, which prevents the software-pipelining loop optimization. Software-pipelining is a key optimization for achieving good performance. You may see reduced performance without software pipelining.
For improved performance, at optimization levels --opt_level=2 (-O2) and --opt_level=3 (-O3), the compiler attempts to software pipeline your loops. Sometimes the compiler may not be able to inline a function call that is in a loop. Because the compiler could not inline the function call, the loop could not be software pipelined, and the loop could not efficiently scheduled.
Typical testcase: In the code below, call to function "func2" prevents software pipelining.
void func1(int *p, int *q, int n) { unsigned int i; for (i = 0; i < n; i++) { int t = func2(i); ; other operations } } int function func2() { . . . }
However if the function func2 is inlined, it:
Automatic inlining is controlled by the "inline" keyword; use it to allow inlining of specific functions :
inline int function func2() { . . . }
The function call "func2" in the loop, prevents software pipelining and better performance. While inlining improves performance, expanding functions inline may increase code size, especially inlining a function that is called in a number of places. Function inlining is optimal for functions that are called only from a small number of places and for small functions.
Inline function call to "func2".
Want to squeeze a few more Performance Cycles out of your application? Leverage the e2e (Engineer-to-Engineer) online community to get all of your Advice questions answered! Or, give back to the community with your expertise.