Dead store elimination removes unused assignment statements. This optimization reduces size and improves speed.
The following table explains how to control the optimization for dead store elimination.
| Turn control this option from here... | use this setting |
|---|---|
| CodeWarrior IDE | Choose Level 3 or Level 4 in the Optimization Level settings panel. |
| source code | #pragma opt_dead_assignments on | off | reset |
| command line | -opt [no]deadstore |
For example, in the following listing the variable x is first assigned the value of y * y. However, this result is not used before x is assigned the result returned by a call to getresult().
void func_from(int x, int y) { x = y * y; otherfunc1(y); x = getresult(); otherfunc2(y); }
In the following listing the compiler can safely remove the first assignment to x since the result of this assignment is never used.
void func_to(int x, int y) { otherfunc1(y); x = getresult(); otherfunc2(y); }