22 Optimizations

The MPLAB XC32 C/C++ Compiler can optimize the assembly code generated from individual modules or from across the whole program. Even when optimization features are enabled, they can only be applied if very specific conditions are met. As a result, you might see that some lines of source code are optimized, but other similar lines are not.

The optimization level determines the available optimizations, which are listed in the following table.

Table 22-1. Optimization Level Sets
LevelOptimization sets available
O0
  • Rudimentary optimizations
O1
  • Minimal code generator optimizations
O2
  • All generic code generator optimizations
  • Minimal assembly optimizations
O3
  • All generic and speed-specific code generator optimizations
  • All generic and speed-specific assembler optimizations
Os
  • All generic and space-specific code generator optimizations
  • All generic and space-specific assembler optimizations