Dead Code Elimination

The dead code elimination optimization removes expressions that are not accessible or are not referred to. This optimization reduces size and increases execution speed.

The following table explains how to control the optimization for dead code elimination.
Table 1. Controlling dead code elimination
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.

Listing: Before dead code elimination

void func_from(void)

{

    if (0)

    {

        func1();

    }

    func2();

}
Listing: After dead code elimination

void func_to(void)

{

    func2();

}