GHINSU:   Statement simplification

- What is statement simplification?
- Example of statement simplification
- Uses of statement simplification

What is statement simplification?

Statement simplification is a code reduction technique that replaces a series of statements in a source program with other equivalent and simpler statements.

Example of statement simplification

An example of expression simplification is given below. Consider the following segment of an original source program:
if (1)
    x = 1;
    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.

Uses of statement simplification

Let us again notice that statement simplification is usually a result of constant propagation and expression simplification. In order to complete the circle of cooperation between these three code reduction techniques, we will also notice that in lines following the program segment of the previous example it is possible to propagate the constant value 1 for the variable x, whereas this was not possible before because it was not known whether the then or the else clause would be executed.

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.

What next?

(o) Contents     (o) Expression simplification     (o) Current status and future work

This page is maintained by Nikos Papaspyrou.
Please, feel free to send your comments, thoughts or suggestions to

Last updated: Monday May 15 1995, 12:05 EET DST.