Coding best practices
How you write your source code can affect the efficiency of the executable code produced by the compiler. For example, loop counters that decrement to zero are generally more efficient than loop counters that increment to an arbitrary value, because the compiler can use a single instruction (
SUBS) to decrement and compare to zero. Writing code that is more efficient delivers not only higher levels of performance, but can also be crucial in conserving battery life. If you can get a job done faster, in fewer cycles, you can turn off the power
for longer periods.
- Coding considerations describes programming practices and techniques to increase the portability, efficiency and robustness of your C and C++ source code.
- Writing optimized code shows how you can use various options, pragmas, attributes, and coding techniques to make best use of the optimization capabilities of Arm Compiler.
- Using inline assembly to improve code efficiency is a tutorial that shows how you can write optimized assembly language routines to improve performance.
- The Cortex-A Programmer's Guide contains an whole chapter (Chapter 17) which discusses how to optimize code to run on Arm processors.