Dead store elimination removes unused assignment statements. This optimization reduces size and improves speed.
Controlling dead store elimination explains how to control the optimization for dead store elimination.
| Turn control this option from here... | use this setting |
|---|---|
| CodeWarrior IDE | Choose an Optimization Level value (3,4) from the Properties > C/C++ Build > Settings > Tool Settings > PowerPC Compiler > Optimization panel. |
| source code | #pragma opt_dead_assignments on | off | reset |
| command line | -opt [no]deadstore |
For example, in Before dead store elimination 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() .
In After dead store elimination the compiler can safely remove the first assignment to x since the result of this assignment is never used.
void func_from(int x, int y)
{
x = y * y;
otherfunc1(y);
x = getresult();
otherfunc2(y);
}
void func_to(int x, int y)
{
otherfunc1(y);
x = getresult();
otherfunc2(y);
}