Copy propagation

In compiler theory, copy propagation is the process of replacing the occurrences of targets of direct assignments with their values.[1] A direct assignment is an instruction of the form x = y, which simply assigns the value of y to x.

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.

Copy propagation is a useful "clean up" optimization frequently used after other optimizations have already been run. Some optimizations—such as elimination of common sub expressions[1]—require that copy propagation be run afterwards in order to achieve an increase in efficiency.

See also

References

  1. 1 2 Aho, Alfred V.; Lam, Monica S.; Sethi, Ravi; Ullman, Jeffrey D. Compilers, Principles, Techniques, & Tools Second edition. ISBN 0-321-48681-1.

Further reading

Muchnick, Steven S. Advanced Compiler Design and Implementation. Morgan Kaufmann. 1997.

This article is issued from Wikipedia - version of the 6/30/2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.