In compiler theorycopy propagation is the process of replacing the occurrences of targets of direct assignments with their values. A direct assignment is a n instruction of the form x = y, which simply assigns the value of y to x. A diagram of the operation of an ideal compiler. ...
From the following code:
y = x z = 3 + y
Copy propagation would yield:
z = 3 + x
Copy propagation often makes use of reaching definitions, use-def chains and def-use chains when computing which occurrences of the target may be safely replaced. If all upwards exposed uses of the target may be safely modified, the assignment operation may be eliminated. In compiler theory, reaching definitions is a data-flow analysis which statically determines which definitions may reach a given point in the code. ... Categories: Wikipedia cleanup | Stub ... This article needs to be cleaned up to conform to a higher standard of quality. ...
Copy propagation is a useful "clean up" optimization frequently used after other optimizations have already been run. Some optimizations require that copy propagation be run afterward in order to achieve an increase in efficiency.
Further Reading
Muchnick, Steven S. Advanced Compiler Design and Implementation. Morgan Kaufmann. 1997.
A more advanced form of constant propagation known as sparse conditional constant propagation may be utilized to simultaneously remove dead code and more accurately propagate constants.
In implementing a cross compiler, care must be taken to ensure that the behaviour of the arithmetic operations on the host architecture matches that on the target architecture, as otherwise enabling constant folding will change the behaviour of the program.
Constant propagation can also cause conditional branches to simplify to one or more unconditional statements, when the conditional expression can be evaluated to true or false at compile time to determine the only possible outcome.
The goal of this assignment is to prepare the constant propagation implementation for the term rewrite system that is the target of the partial evaluator we are developing.
After you have included the copypropagation of variables you are going to extend your code to copypropagate records with variables.
Make sure the copy and constant propagation is working before you start with the copypropagation of records.