Compiler Advice (on TI Wiki)

Advice 27000: Use Optimization Options
Advice 27001: Increase Optimization Level
Advice 27002: Do not turn off software pipelining
Advice 27003: Avoid compiling with debug options
Advice 27004: No Performance Advice generated
Advice 30000: Prevent Loop Disqualification due to call
Advice 30001: Prevent Loop Disqualification due to rts-call
Advice 30002: Prevent Loop Disqualification due to asm statement
Advice 30003: Prevent Loop Disqualification due to complex condition
Advice 30004: Prevent Loop Disqualification due to switch statement
Advice 30005: Prevent Loop Disqualification due to arithmetic operation
Advice 30006: Prevent Loop Disqualification due to call(2)
Advice 30007: Prevent Loop Disqualification due to rts-call(2)
Advice 30008: Improve Loop; Qualify with restrict
Advice 30009: Improve Loop; Add MUST_ITERATE pragma
Advice 30010: Improve Loop; Add MUST_ITERATE pragma(2)
Advice 30011: Improve Loop; Add _nassert()

Typical Advice

 advice #30008: Consider adding the restrict qualifier to the definition
of inp1, inp2 if they don't access the same memory location.

Why is the Compiler giving this Advice ?

This Advice is issued to alert you to a potential performace improvement in your code. The performance of loop mentioned in the Advice can be improved by adding the "restrict" qualifier.


What it means:

To help the compiler determine memory dependencies, you can qualify a pointer, reference, or array with the restrict keyword. The restrict keyword is a type qualifier that can be applied to pointers, references, and arrays. Its use represents a guarantee by you, the programmer, that within the scope of the pointer declaration the object pointed to can be accessed only by that pointer. Any violation of this guarantee renders the program undefined. (For more information on the "restrict" qualifier see Restrict Type Qualifier).

This practice helps the compiler optimize certain sections of code because aliasing information can be more easily determined. In the below example, the restrict keyword is used to tell the compiler that the function func1 is never called with the pointers a and b pointing to objects that overlap in memory. You are promising that accesses through a and b will never conflict; therefore, a write through one pointer cannot affect a read from any other pointers. The precise semantics of the restrict keyword are described in the 1999 version of the ANSI/ISO C Standard.

Example 1: Use of the restrict Type Qualifier With Pointers

 void func1(int * restrict a, int * restrict b)
{
     /* func1's code here */
}

Example 2: Use of the restrict keyword when passing arrays to a function. Here, the arrays c and d should not overlap, nor should c and d point to the same array.

 void func2(int c[restrict], int d[restrict])
{
     int i;
     for(i = 0; i < 64; i++)
     {
        c[i] += d[i];
        d[i] += 1;
     }
}

For further information on conveying information to the compiler to improve performance, see C6000_Compiler: Tuning Software Pipelined Loops and Optimization Lab.


Risks, Severity

When you use mechanisms such as restrict, MUST_ITERATE, or _nassert, you are conveying extra information to the compiler. Always verify all such information is correct for every call.


Suggested Action

Qualify declarations of pointers and arrays used in the loop with "restrict".

More Resources

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.

Go to the TI Compiler's e2e online forum! 

E2e.jpg For technical support please post your questions at http://e2e.ti.com.