Hello every one,
I am working on a S12Z controller in a automotive project with some safety requirements allocated to the controller (ASIL B).
As we are now facing a very high usage of the memory, in particular the ROM, we are considering switching ON the compiler optimization (up to level 2 – size over speed).
In the compiler manual (MCU_S12Z_Compiler.pdf), we can get a very limited amount of information concerning the optimization themselves.
Is there some recommendation whatsoever from NXP about the activation of compiler optimization, in particular in a safety context ? (do not activate at all ? / what to check or to do in addition if you activate ? / anything else ?)
Could anyone provide more details about the compiler optimizations ?
Basically from the compiler manual:
Sets a specific optimization level. The options for num are:
• 0 - Suppress all optimizations
• 1 - High Level Optimizations, Branch Optimization
• 2 - Constant Propagation, Copy Propagation, Dead Code Elimination, Register
Allocation, Peephole, Common Subexpression Elimination, Branch Tail Merge
• 3 - Constant Propagation, Copy Propagation, Dead Code Elimination, Register
Allocation, Peephole, Common Subexpression Elimination, Branch Tail Merge
And
Specify the optimizations that you want the compiler to apply to the generated object code. The options available are as follows:
Off (default) - Disables optimizations. This setting is equivalent to specifying the -O0 command-line option. The compiler generates unoptimized, linear assembly-language code.
1 - The compiler performs all target-independent (that is, nonparallelized) optimizations, such as function inlining. This setting is equivalent to specifying the -O1 command-line option. The compiler omits all target-specific optimizations and generates linear assembly-language code.
2 - The compiler performs all optimizations (both targetindependent and target-specific). This setting is equivalent to specifying the -O2 command-line option. The compiler outputs optimized, non-linear, parallelized assembly-language code.
3 - The compiler performs all the level 2 optimizations, then the low-level optimizer performs global-algorithm register allocation. This setting is equivalent to specifying the -O3 command-line option. At this optimization level, the compiler generates code that is usually faster than the code generated from level 2 optimizations. By default, the optimization is disabled for S12Z Compiler.
Many thanks,
Regards.
Thomas.
HI devauxt
Please turn off compiler optimization if your project is safety requirement.
the optimized code is not strictly equal to the original source code. I haven't see safety required design using optimization.
If I remember correct, NXP S12Z Core Self-Test Software for safety, quality test code all turns of optimization.
Have a nice day,
Jun Zhang