The dead code elimination optimization removes expressions that are not accessible or are not referred to. This optimization reduces size and increases execution speed.
| Turn control this option from here... | use this setting |
|---|---|
| CodeWarrior IDE | Choose Level 1 , Level 2 , Level 3 , or Level 4 in the OptimizationsLevel settings panel. |
| source code | #pragma opt_dead_code on | off | reset |
| command line | -opt [no]deadcode |
In Listing: Before dead code elimination, the call to func1() will never execute because the if statement that it is associated with will never be true. Consequently, the compiler can safely eliminate the call to func1(), as shown in Listing: After dead code elimination.
void func_from(void) { if (0) { func1(); } func2(); }
void func_to(void) { func2(); }