SPRUI04F july 2015 – april 2023
When using the --opt_level=n option (or -On), you are telling the compiler to optimize your code. The higher the value of n, the more effort the compiler invests in optimizing your code. However, you might still need to tell the compiler what your optimization priorities are. By default, when --opt_level=2 or -opt_level=3 is specified, the compiler optimizes primarily for performance. (Under lower optimization levels, the priorities are compilation time and debugging ease.) You can adjust the priorities between performance and code size by using the code size flag --opt_for_space=n. The --opt_for_space=0, --opt_for_space=1, --opt_for_space=2 and --opt_for_space=3 options increasingly favor code size over performance.
When you specify --silicon_version=6400+ in conjunction with the --opt_for_space option, the code will be tailored for compression. That is, more instructions are tailored so they will more likely be converted from 32-bit to 16-bit instructions when assembled.
It is recommended that a code size flag not be used with the most performance-critical code. Using --opt_for_space=0 or --opt_for_space=1 is recommended for all but the most performance-critical code. Using --opt_for_space=2 or --opt_for_space=3 is recommended for seldom-executed code. Either --opt_for_space=2 or --opt_for_space=3 should be used if you need minimum code size. It is generally recommended that the code size flags be combined with --opt_level=2 or --opt_level=3.
If you reduce optimization and/or do not use code size flags, you are disabling code-size optimizations and sacrificing performance.
If you use --opt_for_space with no code size level number specified, the option level defaults to --opt_for_space=0.