if (1)
x = 1;
else
x = 2;
We notice that the condition of the if statement is constant.
We therefore deduce that the then clause is the one that will
be executed and the else clause will be ignored. The original
program is equivalent to the following:
x = 1;
Thus we can substitute the former for the latter and get a much simpler
program.
In the previous example, the statement x = 2;
of the
else clause is not reachable. A series of unreachable
statements is called dead code and can be removed
without affecting the rest of the program. Dead code removal is
another form of statement simplification. A third form is the
removal of code with no effect, that is code
that does not get executed, such as an expression statement whose
expression contains no side effects.
This page is maintained by Nikos Papaspyrou.
Last updated: Monday May 15 1995, 12:05 EET DST.